Re: Re: Spindle compatability test suite
"Hugo Palma" <[email protected]> Tue, 16 May 2006 18:18:40 +0100
| Newsgroups | gmane.comp.ide.eclipse.spindle.devel |
|---|---|
| Message-ID | <[email protected]> |
------=_Part_66023_1451736.1147799920429 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Just hope you and your kids get well soon...... Cheers Hugo On 5/15/06, Geoff Longman <[email protected]> wrote: > > Hey guy. My kids had the flu last week and on Thursday night I got > hit. Just made it out of bed yesterday afternoon and so am a but > behind. > > G > > On 5/13/06, Hugo Palma <[email protected]> wrote: > > Ok, i've uploaded the files. I used the tapidea svn repo for this. > > You have web access to it, if you like, here > > http://svn.javaforge.com/svn/tapidea/spindle-test-suite/trunk/. > > You can also find my(unfinished) implementation of IFixture here > > > http://svn.javaforge.com/svn/tapidea/tapidea-core/trunk/src/main/java/org= /intellij/tapestry/test/Fixture.java > . > > > > I thought a little more about the tested classes implementation issue > > and i think i came up with a much better solution. Instead of having to > > declare a service for each tested class i think we can assume that if w= e > > have the IDE specific implementation of ITapestryProject and > > TapestryCore we can get any other instance of a class that we want to > > test from that. The current implementation only gets the > > ITapestryProject implementation but a similiar approach can be taken to > > get the TapestryCore impl. > > Do you think this assumption is correct ? > > > > > > > > Geoff Longman wrote: > > > Ok. I see what you have. A fixture is an interface to build a > > > "project" with context and classpath for testing. Can provide or poin= t > > > me to (in you repo) an example of a Test? > > > > > > > > > On 5/10/06, Hugo Palma <[email protected]> wrote: > > >> Forgot to mention how the tested class implementation would be serve= d > to > > >> the test class. > > > > > > ok, I'm lost at this point. "tested class implementation" is? > > > > > > > > > Geoff > > > > > >> I got this working by declaring a hivemind service for each tested > class > > >> in spindle-tests and then providing the implementation in the IDE > > >> implementation module. There's also an utility method in > > >> AbstractSpindleTestCase that gets the tested class implementation. > > >> I'm not crazy about having to declare every tested class in the > hivemind > > >> descriptor but i couldn't find a better way of doing this. > > >> > > >> > > >> Hugo Palma wrote: > > >> > I told you i wouldn't let you forget about this :o) > > >> > > > >> > I took advantage of a few dead hours in my day job to give this > some > > >> > thought. After some experimenting i came up with some ideas and > some > > >> > code also. > > >> > > > >> > There should be a separate module(spindle-tests) with all the > > >> > framework classes and the tests themselves. > > >> > > > >> > The framework consists of one interface, one class and one hivemin= d > > >> > descriptor. The interface is IFixture, it provides the signature > for > > >> > all operations that can be executed in a fixture. A fresh instance > of > > >> > the fixture will be provided to each test class at every test run. > > >> > I've come up with the following code for now, still some operation= s > > >> > missing but good for getting the main picture: > > >> > > > >> > /** > > >> > * A test fixture. Should have an implementation for each IDE. > > >> > */ > > >> > public interface IFixture<W, F> > > >> > { > > >> > /** > > >> > * Adds a web root. > > >> > * > > >> > * @param filePath the absolute path to the web root > > >> directory. > > >> > * @param relativePath the relative path of the web root. Some > > >> > IDEs let the user specify a different relative path for each web > root, > > >> > changing the default "/" path. > > >> > * @return the added web root. > > >> > */ > > >> > W addWebRoot(String filePath, String relativePath); > > >> > > > >> > /** > > >> > * Adds a web root with the default "/" relative path. > > >> > * > > >> > * @param filePath the absolute path to the web root directory= . > > >> > * @return the added web root. > > >> > */ > > >> > W addWebRoot(String filePath); > > >> > > > >> > /** > > >> > * Adds an empty file to a web root. > > >> > * > > >> > * @param webRoot the web root to add the file to. > > >> > * @param path the absolute path of the file to be added. > > >> > * @return the added file. > > >> > */ > > >> > F addFileToWebRoot(W webRoot, String path); > > >> > > > >> > /** > > >> > * Adds a source root. > > >> > * > > >> > * @param filePath the absolute path to the source root > directory. > > >> > * @return the added source root. > > >> > */ > > >> > F addSourceRoot(String filePath); > > >> > > > >> > /** > > >> > * Adds an empty class to a source root. > > >> > * > > >> > * @param root the source root to add the class to. > > >> > * @param packageName the class package. > > >> > * @param className the class name. > > >> > */ > > >> > void addClassToSourceRoot(F root, String packageName, String > > >> > className); > > >> > > > >> > /** > > >> > * Adds a .jar file to the classpath. > > >> > * > > >> > * @param jarFile the .jar file to add to the classpath. > > >> > */ > > >> > void addJarToClasspath(F jarFile); > > >> > > > >> > /** > > >> > * Adds a file to a source root. > > >> > * > > >> > * @param root the source root to add the file to. > > >> > * @param packageName the package to add the file to. > > >> > * @param fileName the absolute path to the file to be > added. > > >> > */ > > >> > void addFileToSourceRoot(F root, String packageName, String > > >> > fileName); > > >> > > > >> > /** > > >> > * Tears down the fixture. > > >> > */ > > >> > void tearDown(); > > >> > } > > >> > > > >> > > > >> > The base class for all tests is also provided. I called it > > >> > AbstractSpindleTestCase. This class provides a getFixture() method > to > > >> > every subclass and is responsible for getting the fresh fixture > > >> > instance from Hivemind at every test run. Here's the code i came u= p > > >> with: > > >> > > > >> > /** > > >> > * Base class for all test classes. > > >> > * > > >> > * @author Hugo Palma > > >> > */ > > >> > public abstract class AbstractSpindleTestCase extends TestCase > > >> > { > > >> > private IFixture _fixture; > > >> > private static Registry _registry; > > >> > > > >> > { > > >> > _registry =3D RegistryBuilder.constructDefaultRegistry(); > > >> > } > > >> > > > >> > /** > > >> > * {@inheritDoc} > > >> > */ > > >> > protected void setUp() throws Exception > > >> > { > > >> > super.setUp(); > > >> > > > >> > // Allows getting a brand new IFixture instance every time= . > > >> > _registry.cleanupThread(); > > >> > _registry.setupThread(); > > >> > > > >> > _fixture =3D (IFixture) _registry.getService(IFixture.clas= s); > > >> > } > > >> > > > >> > /** > > >> > * {@inheritDoc} > > >> > */ > > >> > protected void tearDown() throws Exception > > >> > { > > >> > super.tearDown(); > > >> > > > >> > // Cleanup the fixture. > > >> > _fixture.tearDown(); > > >> > _fixture =3D null; > > >> > } > > >> > > > >> > protected IFixture getFixture() > > >> > { > > >> > return _fixture; > > >> > } > > >> > } > > >> > > > >> > The only thing missing is the hivemodule.xml in the spindle-tests > > >> module: > > >> > > > >> > <module id=3D" net.sf.spindle.tests" version=3D"1.0.0"> > > >> > <service-point id=3D"fixture" > > >> > interface=3D"net.sf.spindle.tests.IFixture"/> > > >> > </module> > > >> > > > >> > So, given this, all the IDE has to do is: > > >> > > > >> > - Create an implementation of the IFixture interface. > > >> > - Provide a hivemodule.xml file in it's spindle-core implementatio= n > > >> > module with something like: > > >> > > > >> > <module id=3D"org.intellij.tapestry" version=3D" 1.0.0"> > > >> > <dependency module-id=3D"net.sf.spindle.tests" version=3D"1.0.= 0"/> > > >> > > > >> > <implementation service-id=3D"net.sf.spindle.tests.fixture"> > > >> > <invoke-factory model=3D"threaded"> > > >> > <construct class=3D"org.intellij.tapestry.test.Fixture= "/> > > >> > </invoke-factory> > > >> > </implementation> > > >> > </module> > > >> > - Execute the tests. I managed to run the tests from IDEA with no > > >> > problem. I'm going to see how/if i can run tests from a jar file > with > > >> > Maven2. > > >> > > > >> > > > >> > Thoughts ? > > >> > > >> > > >> ------------------------------------------------------- > > >> Using Tomcat but need to do more? Need to support web services, > > >> security? > > >> Get stuff done quickly with pre-integrated technology to make your > > >> job easier > > >> Download IBM WebSphere Application Server v.1.0.1 based on Apache > > >> Geronimo > > >> > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D120709&bid=3D263057&dat= =3D121642 > > >> _______________________________________________ > > >> Spindle-developer mailing list > > >> [email protected] > > >> https://lists.sourceforge.net/lists/listinfo/spindle-developer > > >> > > > > > > > > > > > > ------------------------------------------------------- > > Using Tomcat but need to do more? Need to support web services, > security? > > Get stuff done quickly with pre-integrated technology to make your job > easier > > Download IBM WebSphere Application Server v.1.0.1 based on Apache > Geronimo > > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D120709&bid=3D263057&dat= =3D121642 > > _______________________________________________ > > Spindle-developer mailing list > > [email protected] > > https://lists.sourceforge.net/lists/listinfo/spindle-developer > > > > > -- > The Spindle guy. http://spindle.sf.net > Blog: http://jroller.com/page/glongman > Other interests: http://www.squidoo.com/spaceelevator/ > > > ------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job > easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronim= o > http://sel.as-us.falkag.net/sel?cmdlnk&kid=120709&bid&3057&dat=121642 > _______________________________________________ > Spindle-developer mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/spindle-developer > ------=_Part_66023_1451736.1147799920429 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Just hope you and your kids get well soon......<br><br>Cheers<br><br>Hugo<b= r><br><div><span class=3D"gmail_quote">On 5/15/06, <b class=3D"gmail_sender= name">Geoff Longman</b> <<a href=3D"mailto:[email protected]">glongman@= gmail.com </a>> wrote:</span><blockquote class=3D"gmail_quote" style=3D"border-lef= t: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1= ex;">Hey guy. My kids had the flu last week and on Thursday night I got<br> hit. Just made it out of bed yesterday afternoon and so am a but<br>behind.= <br><br>G<br><br>On 5/13/06, Hugo Palma <<a href=3D"mailto:hugo.m.palma@= gmail.com">[email protected]</a>> wrote:<br>> Ok, i've uploaded = the files. I used the tapidea svn repo for this. <br>> You have web access to it, if you like, here<br>> <a href=3D"ht= tp://svn.javaforge.com/svn/tapidea/spindle-test-suite/trunk/">http://svn.ja= vaforge.com/svn/tapidea/spindle-test-suite/trunk/</a>.<br>> You can also= find my(unfinished) implementation of IFixture here <br>> <a href=3D"http://svn.javaforge.com/svn/tapidea/tapidea-core/trunk= /src/main/java/org/intellij/tapestry/test/Fixture.java">http://svn.javaforg= e.com/svn/tapidea/tapidea-core/trunk/src/main/java/org/intellij/tapestry/te= st/Fixture.java </a>.<br>><br>> I thought a little more about the tested classes impl= ementation issue<br>> and i think i came up with a much better solution.= Instead of having to<br>> declare a service for each tested class i thi= nk we can assume that if we <br>> have the IDE specific implementation of ITapestryProject and<br>&g= t; TapestryCore we can get any other instance of a class that we want to<br= >> test from that. The current implementation only gets the<br>> ITap= estryProject implementation but a similiar approach can be taken to <br>> get the TapestryCore impl.<br>> Do you think this assumption is= correct ?<br>><br>><br>><br>> Geoff Longman wrote:<br>> >= ; Ok. I see what you have. A fixture is an interface to build a<br>> >= ; "project" with context and classpath for testing. Can provide o= r point <br>> > me to (in you repo) an example of a Test?<br>> ><br>>= ; ><br>> > On 5/10/06, Hugo Palma <<a href=3D"mailto:hugo.m.pal= [email protected]">[email protected]</a>> wrote:<br>> >> Forgot= to mention how the tested class implementation would be served to <br>> >> the test class.<br>> ><br>> > ok, I'm lost at= this point. "tested class implementation" is?<br>> ><br>&g= t; ><br>> > Geoff<br>> ><br>> >> I got this working= by declaring a hivemind service for each tested class <br>> >> in spindle-tests and then providing the implementation in= the IDE<br>> >> implementation module. There's also an utility me= thod in<br>> >> AbstractSpindleTestCase that gets the tested class= implementation. <br>> >> I'm not crazy about having to declare every tested class = in the hivemind<br>> >> descriptor but i couldn't find a better wa= y of doing this.<br>> >><br>> >><br>> >> Hugo Pa= lma wrote: <br>> >> > I told you i wouldn't let you forget about this :o)<= br>> >> ><br>> >> > I took advantage of a few dead = hours in my day job to give this some<br>> >> > thought. After = some experimenting i came up with some ideas and some <br>> >> > code also.<br>> >> ><br>> >> &g= t; There should be a separate module(spindle-tests) with all the<br>> &g= t;> > framework classes and the tests themselves.<br>> >> &g= t; <br>> >> > The framework consists of one interface, one class a= nd one hivemind<br>> >> > descriptor. The interface is IFixture= , it provides the signature for<br>> >> > all operations that c= an be executed in a fixture. A fresh instance of <br>> >> > the fixture will be provided to each test class at e= very test run.<br>> >> > I've come up with the following code f= or now, still some operations<br>> >> > missing but good for ge= tting the main picture: <br>> >> ><br>> >> > /**<br>> >> > = ; * A test fixture. Should have an implementation for each IDE.<br>>= ; >> > */<br>> >> > public interface IFixtu= re<W, F><br> > >> > {<br>> >> > /**<br>&= gt; >> > * Adds a web root.<br>= > >> > *<br>> >> &g= t; * @param filePath &n= bsp; the absolute path to the web root<br>> >> directory. <br>> >> > * @param relative= Path the relative path of the web root. Some<br>> >> > IDEs let= the user specify a different relative path for each web root,<br>> >= > > changing the default "/" path. <br>> >> > * @return the add= ed web root.<br>> >> > */<br= >> >> > W addWebRoot(String filePath, S= tring relativePath);<br>> >> ><br>> >> >  = ; /**<br> > >> > * Adds a web root wit= h the default "/" relative path.<br>> >> >  = ; *<br>> >> > &nb= sp; * @param filePath the absolute path to the web root directory.<br>= > >> > * @return the added w= eb root. <br>> >> > */<br>> >&g= t; > W addWebRoot(String filePath);<br>> >= > ><br>> >> > /**<br>> >>= ; > * Adds an empty file to a web roo= t.<br>> >> > * <br>> >> > * @param webRoot = the web root to add the file to.<br>> >> > &nb= sp; * @param path the absolute path of th= e file to be added.<br>> >> > &nbs= p;* @return the added file.<br> > >> > */<br>> >> &= gt; F addFileToWebRoot(W webRoot, String path);<br>= > >> ><br>> >> > /**<br>>= ; >> > * Adds a source root.<br= >> >> > * <br>> >> > * @param filePath= the absolute path to the source root directory.<br>> >> > = ; * @return the added source root.<br>> >= ;> > */<br>> >> > = ; F addSourceRoot(String filePath); <br>> >> ><br>> >> > /**<br= >> >> > * Adds an empty clas= s to a source root.<br>> >> > &nbs= p;*<br>> >> > * @param root&= nbsp; the source root to add the c= lass to. <br>> >> > * @param packageN= ame the class package.<br>> >> > &= nbsp;* @param className the class name.<br>> >> >&n= bsp; */<br>> >> >  = ; void addClassToSourceRoot(F root, String packageName, String <br>> >> > className);<br>> >> ><br>> >> &= gt; /**<br>> >> > &nbs= p; * Adds a .jar file to the classpath.<br>> >> >&nb= sp; *<br>> >> > &= nbsp; * @param jarFile the .jar file to add to the classpath. <br>> >> > */<br>> >&g= t; > void addJarToClasspath(F jarFile);<br>> = >> ><br>> >> > /**<br>> >= ;> > * Adds a file to a source roo= t.<br>> >> > * <br>> >> > * @param root&nbs= p; the source root to add the file= to.<br>> >> > * @param pack= ageName the package to add the file to.<br>> >> > &n= bsp; * @param fileName the absolute= path to the file to be added. <br>> >> > */<br>> >&g= t; > void addFileToSourceRoot(F root, String pac= kageName, String<br>> >> > fileName);<br>> >> ><br>= > >> > /**<br>> >> > &= nbsp; * Tears down the fixture. <br>> >> > */<br>> >&g= t; > void tearDown();<br>> >> > }<br= >> >> ><br>> >> ><br>> >> > The base cl= ass for all tests is also provided. I called it <br>> >> > AbstractSpindleTestCase. This class provides a getFi= xture() method to<br>> >> > every subclass and is responsible f= or getting the fresh fixture<br>> >> > instance from Hivemind a= t every test run. Here's the code i came up <br>> >> with:<br>> >> ><br>> >> > /**<br>= > >> > * Base class for all test classes.<br>> &g= t;> > *<br>> >> > * @author Hugo Pa= lma<br>> >> > */ <br>> >> > public abstract class AbstractSpindleTestCase extend= s TestCase<br>> >> > {<br>> >> > &= nbsp; private IFixture _fixture;<br>> >> > &nb= sp; private static Registry _registry; <br>> >> ><br>> >> > {<br>&= gt; >> > _registry= =3D RegistryBuilder.constructDefaultRegistry();<br>> >> > = ; }<br>> >> ><br>> >> > &nbs= p; /**<br>> >> >  = ;* {@inheritDoc} <br>> >> > */<br>> >&g= t; > protected void setUp() throws Exception<br>= > >> > {<br>> >> > &nb= sp; super.setUp();<br>> >> >= ;<br>> >> > // = Allows getting a brand new IFixture instance every time. <br>> >> > _reg= istry.cleanupThread();<br>> >> > &= nbsp; _registry.setupThread();<br>> >> ><br>> &g= t;> > _fixture =3D (I= Fixture) _registry.getService(IFixture.class );<br>> >> > }<br>> >> ><b= r>> >> > /**<br>> >> > = ; * {@inheritDoc}<br>> >> > &= nbsp; */<br>> >> > &nbs= p; protected void tearDown() throws Exception <br>> >> > {<br>> >> > = ; super.tearDown();<br>> >&= gt; ><br>> >> > &nb= sp; // Cleanup the fixture.<br>> >> > &n= bsp; _fixture.tearDown();<br>> >> > &nbs= p; _fixture =3D null; <br>> >> > }<br>> >> ><br>&= gt; >> > protected IFixture getFixture()<b= r>> >> > {<br>> >> > &= nbsp; return _fixture;<br>> >>= > }<br>> >> > } <br>> >> ><br>> >> > The only thing missing is the = hivemodule.xml in the spindle-tests<br>> >> module:<br>> >&g= t; ><br>> >> > <module id=3D" net.sf.spindle.tests " version=3D"1.0.0"><br>> >> > &nb= sp; <service-point id=3D"fixture"<br>> >> > = interface=3D"net.sf.spindle.tests.IFixture"/><br>> >>= > </module><br> > >> ><br>> >> > So, given this, all the IDE has to= do is:<br>> >> ><br>> >> > - Create an implementat= ion of the IFixture interface.<br>> >> > - Provide a hivemodule= .xml file in it's spindle-core implementation<br>> >> > module with= something like:<br>> >> ><br>> >> > &l= t;module id=3D"org.intellij.tapestry" version=3D" 1.0.0"= ;><br>> >> > <dependency module-i= d=3D" net.sf.spindle.tests" version=3D"1.0.0"/><br>> >>= ; ><br>> >> > <implementation ser= vice-id=3D"net.sf.spindle.tests.fixture"><br>> >> >= ; <invoke-factory model= =3D"threaded"> <br>> >> >  = ; <construct class=3D"org.intellij.tapestry.test.= Fixture"/><br>> >> >  = ; </invoke-factory><br>> >> > &nbs= p; </implementation><br>> >> > </module> <br>> >> > - Execute the tests. I managed to run the tests from= IDEA with no<br>> >> > problem. I'm going to see how/if i can = run tests from a jar file with<br>> >> > Maven2.<br>> >&g= t; > <br>> >> ><br>> >> > Thoughts ?<br>> >><br= >> >><br>> >> -------------------------------------------= ------------<br>> >> Using Tomcat but need to do more? Need to sup= port web services, <br>> >> security?<br>> >> Get stuff done quickly with pr= e-integrated technology to make your<br>> >> job easier<br>> &g= t;> Download IBM WebSphere Application Server v.1.0.1 based on Apache <br>> >> Geronimo<br>> >> <a href=3D"http://sel.as-us.fal= kag.net/sel?cmd=3Dlnk&kid=3D120709&bid=3D263057&dat=3D121642">h= ttp://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D120709&bid=3D263057&= amp;dat=3D121642 </a><br>> >> _______________________________________________<br>&g= t; >> Spindle-developer mailing list<br>> >> <a href=3D"mail= to:[email protected]">[email protected]= orge.net </a><br>> >> <a href=3D"https://lists.sourceforge.net/lists/listin= fo/spindle-developer">https://lists.sourceforge.net/lists/listinfo/spindle-= developer</a><br>> >><br>> ><br>> ><br>><br>><br= > > -------------------------------------------------------<br>> Using = Tomcat but need to do more? Need to support web services, security?<br>>= Get stuff done quickly with pre-integrated technology to make your job eas= ier <br>> Download IBM WebSphere Application Server v.1.0.1 based on Apache = Geronimo<br>> <a href=3D"http://sel.as-us.falkag.net/sel?cmd=3Dlnk&k= id=3D120709&bid=3D263057&dat=3D121642">http://sel.as-us.falkag.net/= sel?cmd=3Dlnk&kid=3D120709&bid=3D263057&dat=3D121642 </a><br>> _______________________________________________<br>> Spindl= e-developer mailing list<br>> <a href=3D"mailto:Spindle-developer@lists.= sourceforge.net">[email protected]</a><br>> <a hre= f=3D"https://lists.sourceforge.net/lists/listinfo/spindle-developer"> https://lists.sourceforge.net/lists/listinfo/spindle-developer</a><br>><= br><br><br>--<br>The Spindle guy. <a href=3D"http://spindle.sf.net">http://= spindle.sf.net</a><br>Blog: = <a href=3D"http= ://jroller.com/page/glongman"> http://jroller.com/page/glongman</a><br>Other interests: <a href= =3D"http://www.squidoo.com/spaceelevator/">http://www.squidoo.com/spaceelev= ator/</a><br><br><br>------------------------------------------------------= -<br>Using Tomcat but need to do more? Need to support web services, securi= ty? <br>Get stuff done quickly with pre-integrated technology to make your job = easier<br>Download IBM WebSphere Application Server v.1.0.1 based on Apache= Geronimo<br><a href=3D"http://sel.as-us.falkag.net/sel?cmdlnk&kid=1207= 09&bid&3057&dat=121642"> http://sel.as-us.falkag.net/sel?cmdlnk&kid=120709&bid&3057&= dat=121642</a><br>_______________________________________________<br>Spindl= e-developer mailing list<br><a href=3D"mailto:[email protected]= eforge.net"> [email protected]</a><br><a href=3D"https://lists.sou= rceforge.net/lists/listinfo/spindle-developer">https://lists.sourceforge.ne= t/lists/listinfo/spindle-developer</a><br></blockquote></div><br> ------=_Part_66023_1451736.1147799920429-- ------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642