starting jetty during tests and stopping afterwards
Is there a clean way to start up jetty for the testing and then stopping git afterwards? I'd like to include my integration tests for my code coverage. I'd like to set my code coverage profile to only start up jetty after cobertura has instrumented the classes then shut it down after the tests complete. Could I just start up the jetty in process-test-classes and shut it down in prepare-package? D/ - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: starting jetty during tests and stopping afterwards
On 04/03/2010, at 8:49 PM, Douglas Ferguson wrote: > Is there a clean way to start up jetty for the testing and then stopping git > afterwards? > > I'd like to include my integration tests for my code coverage. > > I'd like to set my code coverage profile to only start up jetty after > cobertura has instrumented the classes > then shut it down after the tests complete. > > Could I just start up the jetty in process-test-classes and shut it down in > prepare-package? Yep. http://github.com/brettporter/centrepoint/blob/master/centrepoint/modules/selenium-tests/pom.xml Bear in mind that if the tests fail, the "stop" won't be run, but normally they will shut down properly when Maven does anyway. - Brett -- Brett Porter br...@apache.org http://brettporter.wordpress.com/ - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: starting jetty during tests and stopping afterwards
Brett, you could always rebind failsafe:integration-test to the test phase so that the server will be torn down in the event of failing tests -Stephen On 4 March 2010 10:05, Brett Porter wrote: > On 04/03/2010, at 8:49 PM, Douglas Ferguson wrote: > > > Is there a clean way to start up jetty for the testing and then stopping > git afterwards? > > > > I'd like to include my integration tests for my code coverage. > > > > I'd like to set my code coverage profile to only start up jetty after > cobertura has instrumented the classes > > then shut it down after the tests complete. > > > > Could I just start up the jetty in process-test-classes and shut it down > in prepare-package? > > Yep. > > > http://github.com/brettporter/centrepoint/blob/master/centrepoint/modules/selenium-tests/pom.xml > > Bear in mind that if the tests fail, the "stop" won't be run, but normally > they will shut down properly when Maven does anyway. > > - Brett > > -- > Brett Porter > br...@apache.org > http://brettporter.wordpress.com/ > > > > > > - > To unsubscribe, e-mail: users-unsubscr...@maven.apache.org > For additional commands, e-mail: users-h...@maven.apache.org > >
Re: starting jetty during tests and stopping afterwards
I've been experimenting with this and have come to find out that the mvn jetty plugin is not compatible with projects that include jetty in their pom dependencies. Now I need to figure out a different way to start up jetty. I have a Start.java class that could start up jetty but i would need to figure out how to stop it. Also, I'm found some information online about a version cobertura plugin that had a seperate generate-report goal. Anybody know where I could locate this? D/ On Mar 4, 2010, at 4:05 AM, Brett Porter wrote: > On 04/03/2010, at 8:49 PM, Douglas Ferguson wrote: > >> Is there a clean way to start up jetty for the testing and then stopping git >> afterwards? >> >> I'd like to include my integration tests for my code coverage. >> >> I'd like to set my code coverage profile to only start up jetty after >> cobertura has instrumented the classes >> then shut it down after the tests complete. >> >> Could I just start up the jetty in process-test-classes and shut it down in >> prepare-package? > > Yep. > > http://github.com/brettporter/centrepoint/blob/master/centrepoint/modules/selenium-tests/pom.xml > > Bear in mind that if the tests fail, the "stop" won't be run, but normally > they will shut down properly when Maven does anyway. > > - Brett > > -- > Brett Porter > br...@apache.org > http://brettporter.wordpress.com/ > > > > > > - > To unsubscribe, e-mail: users-unsubscr...@maven.apache.org > For additional commands, e-mail: users-h...@maven.apache.org > - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: starting jetty during tests and stopping afterwards
public final class JettyHelper { private JettyHelper() { throw new IllegalAccessError("Utility class"); } public static Server createServer(int port, File warFile, String contextRoot) throws Exception { Server server = new Server(); Connector connector = new SelectChannelConnector(); connector.setPort(port); server.addConnector(connector); WebAppContext context = new WebAppContext(warFile.getAbsolutePath(), contextRoot); context.setConfigurationClasses(new String[]{ "org.mortbay.jetty.webapp.WebInfConfiguration", "org.mortbay.jetty.plus.webapp.EnvConfiguration", "org.mortbay.jetty.annotations.Configuration", "org.mortbay.jetty.webapp.JettyWebXmlConfiguration", "org.mortbay.jetty.webapp.TagLibConfiguration" }); context.setExtractWAR(false); context.setCopyWebDir(false); context.setParentLoaderPriority(true); server.setHandler(context); server.start(); return server; } public static void destroyServer(Server server) throws Exception { if (server == null) return; if (!server.isStopped()) { server.stop(); server.join(); } } } On 4 March 2010 11:58, Douglas Ferguson wrote: > I've been experimenting with this and have come to find out that the mvn > jetty plugin is not compatible with projects that include jetty in their pom > dependencies. > > Now I need to figure out a different way to start up jetty. I have a > Start.java class that could start up jetty but i would need to figure out > how to stop it. > > Also, I'm found some information online about a version cobertura plugin > that had a seperate generate-report goal. Anybody know where I could locate > this? > > D/ > > On Mar 4, 2010, at 4:05 AM, Brett Porter wrote: > > > On 04/03/2010, at 8:49 PM, Douglas Ferguson wrote: > > > >> Is there a clean way to start up jetty for the testing and then stopping > git afterwards? > >> > >> I'd like to include my integration tests for my code coverage. > >> > >> I'd like to set my code coverage profile to only start up jetty after > cobertura has instrumented the classes > >> then shut it down after the tests complete. > >> > >> Could I just start up the jetty in process-test-classes and shut it down > in prepare-package? > > > > Yep. > > > > > http://github.com/brettporter/centrepoint/blob/master/centrepoint/modules/selenium-tests/pom.xml > > > > Bear in mind that if the tests fail, the "stop" won't be run, but > normally they will shut down properly when Maven does anyway. > > > > - Brett > > > > -- > > Brett Porter > > br...@apache.org > > http://brettporter.wordpress.com/ > > > > > > > > > > > > - > > To unsubscribe, e-mail: users-unsubscr...@maven.apache.org > > For additional commands, e-mail: users-h...@maven.apache.org > > > > > - > To unsubscribe, e-mail: users-unsubscr...@maven.apache.org > For additional commands, e-mail: users-h...@maven.apache.org > >
Re: starting jetty during tests and stopping afterwards
Hmm.. But how would I start that and stop it with mvn? Looks like you'd need to have a reference to the instantiated JettyHelp in order to stop it. D/ On Mar 4, 2010, at 6:07 AM, Stephen Connolly wrote: > public final class JettyHelper { > >private JettyHelper() { >throw new IllegalAccessError("Utility class"); >} > >public static Server createServer(int port, File warFile, String > contextRoot) throws Exception { > >Server server = new Server(); >Connector connector = new SelectChannelConnector(); >connector.setPort(port); >server.addConnector(connector); > >WebAppContext context = new WebAppContext(warFile.getAbsolutePath(), > contextRoot); > >context.setConfigurationClasses(new String[]{ >"org.mortbay.jetty.webapp.WebInfConfiguration", >"org.mortbay.jetty.plus.webapp.EnvConfiguration", >"org.mortbay.jetty.annotations.Configuration", >"org.mortbay.jetty.webapp.JettyWebXmlConfiguration", >"org.mortbay.jetty.webapp.TagLibConfiguration" >}); > >context.setExtractWAR(false); >context.setCopyWebDir(false); >context.setParentLoaderPriority(true); > >server.setHandler(context); > >server.start(); > >return server; >} > >public static void destroyServer(Server server) throws Exception { >if (server == null) return; >if (!server.isStopped()) { >server.stop(); >server.join(); >} >} > } > > > On 4 March 2010 11:58, Douglas Ferguson wrote: > >> I've been experimenting with this and have come to find out that the mvn >> jetty plugin is not compatible with projects that include jetty in their pom >> dependencies. >> >> Now I need to figure out a different way to start up jetty. I have a >> Start.java class that could start up jetty but i would need to figure out >> how to stop it. >> >> Also, I'm found some information online about a version cobertura plugin >> that had a seperate generate-report goal. Anybody know where I could locate >> this? >> >> D/ >> >> On Mar 4, 2010, at 4:05 AM, Brett Porter wrote: >> >>> On 04/03/2010, at 8:49 PM, Douglas Ferguson wrote: >>> Is there a clean way to start up jetty for the testing and then stopping >> git afterwards? I'd like to include my integration tests for my code coverage. I'd like to set my code coverage profile to only start up jetty after >> cobertura has instrumented the classes then shut it down after the tests complete. Could I just start up the jetty in process-test-classes and shut it down >> in prepare-package? >>> >>> Yep. >>> >>> >> http://github.com/brettporter/centrepoint/blob/master/centrepoint/modules/selenium-tests/pom.xml >>> >>> Bear in mind that if the tests fail, the "stop" won't be run, but >> normally they will shut down properly when Maven does anyway. >>> >>> - Brett >>> >>> -- >>> Brett Porter >>> br...@apache.org >>> http://brettporter.wordpress.com/ >>> >>> >>> >>> >>> >>> - >>> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org >>> For additional commands, e-mail: users-h...@maven.apache.org >>> >> >> >> - >> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org >> For additional commands, e-mail: users-h...@maven.apache.org >> >> - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: starting jetty during tests and stopping afterwards
Why would you insist on starting it with mvn? How do you run the the same test in your IDE? Wouldn't it be easier to just use JettyHelper in your test? For another example of the same concept, perhaps a bit more evolved, see http://svn.codehaus.org/tynamo/trunk/tapestry-model/tapestry-model-test/src/main/java/org/tynamo/test/AbstractContainerTest.java (http://tynamo.org) Kalle On Thu, Mar 4, 2010 at 9:38 AM, Douglas Ferguson wrote: > Hmm.. But how would I start that and stop it with mvn? Looks like you'd need > to have a reference to the instantiated JettyHelp in order to stop it. > > D/ > > On Mar 4, 2010, at 6:07 AM, Stephen Connolly wrote: > >> public final class JettyHelper { >> >> private JettyHelper() { >> throw new IllegalAccessError("Utility class"); >> } >> >> public static Server createServer(int port, File warFile, String >> contextRoot) throws Exception { >> >> Server server = new Server(); >> Connector connector = new SelectChannelConnector(); >> connector.setPort(port); >> server.addConnector(connector); >> >> WebAppContext context = new WebAppContext(warFile.getAbsolutePath(), >> contextRoot); >> >> context.setConfigurationClasses(new String[]{ >> "org.mortbay.jetty.webapp.WebInfConfiguration", >> "org.mortbay.jetty.plus.webapp.EnvConfiguration", >> "org.mortbay.jetty.annotations.Configuration", >> "org.mortbay.jetty.webapp.JettyWebXmlConfiguration", >> "org.mortbay.jetty.webapp.TagLibConfiguration" >> }); >> >> context.setExtractWAR(false); >> context.setCopyWebDir(false); >> context.setParentLoaderPriority(true); >> >> server.setHandler(context); >> >> server.start(); >> >> return server; >> } >> >> public static void destroyServer(Server server) throws Exception { >> if (server == null) return; >> if (!server.isStopped()) { >> server.stop(); >> server.join(); >> } >> } >> } >> >> >> On 4 March 2010 11:58, Douglas Ferguson wrote: >> >>> I've been experimenting with this and have come to find out that the mvn >>> jetty plugin is not compatible with projects that include jetty in their pom >>> dependencies. >>> >>> Now I need to figure out a different way to start up jetty. I have a >>> Start.java class that could start up jetty but i would need to figure out >>> how to stop it. >>> >>> Also, I'm found some information online about a version cobertura plugin >>> that had a seperate generate-report goal. Anybody know where I could locate >>> this? >>> >>> D/ >>> >>> On Mar 4, 2010, at 4:05 AM, Brett Porter wrote: >>> On 04/03/2010, at 8:49 PM, Douglas Ferguson wrote: > Is there a clean way to start up jetty for the testing and then stopping >>> git afterwards? > > I'd like to include my integration tests for my code coverage. > > I'd like to set my code coverage profile to only start up jetty after >>> cobertura has instrumented the classes > then shut it down after the tests complete. > > Could I just start up the jetty in process-test-classes and shut it down >>> in prepare-package? Yep. >>> http://github.com/brettporter/centrepoint/blob/master/centrepoint/modules/selenium-tests/pom.xml Bear in mind that if the tests fail, the "stop" won't be run, but >>> normally they will shut down properly when Maven does anyway. - Brett -- Brett Porter br...@apache.org http://brettporter.wordpress.com/ - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org >>> >>> >>> - >>> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org >>> For additional commands, e-mail: users-h...@maven.apache.org >>> >>> > > > - > To unsubscribe, e-mail: users-unsubscr...@maven.apache.org > For additional commands, e-mail: users-h...@maven.apache.org > > - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: starting jetty during tests and stopping afterwards
I have 20 tests and the number is growing. I don't want to start and stop jetty for every test, because hibernate and guice intialize actually take a little bit of time. Which would slow down the entire suite.. D/ On Mar 4, 2010, at 12:17 PM, Kalle Korhonen wrote: > Why would you insist on starting it with mvn? How do you run the the > same test in your IDE? Wouldn't it be easier to just use JettyHelper > in your test? For another example of the same concept, perhaps a bit > more evolved, see > http://svn.codehaus.org/tynamo/trunk/tapestry-model/tapestry-model-test/src/main/java/org/tynamo/test/AbstractContainerTest.java > (http://tynamo.org) > > Kalle > > > On Thu, Mar 4, 2010 at 9:38 AM, Douglas Ferguson > wrote: >> Hmm.. But how would I start that and stop it with mvn? Looks like you'd need >> to have a reference to the instantiated JettyHelp in order to stop it. >> >> D/ >> >> On Mar 4, 2010, at 6:07 AM, Stephen Connolly wrote: >> >>> public final class JettyHelper { >>> >>>private JettyHelper() { >>>throw new IllegalAccessError("Utility class"); >>>} >>> >>>public static Server createServer(int port, File warFile, String >>> contextRoot) throws Exception { >>> >>>Server server = new Server(); >>>Connector connector = new SelectChannelConnector(); >>>connector.setPort(port); >>>server.addConnector(connector); >>> >>>WebAppContext context = new WebAppContext(warFile.getAbsolutePath(), >>> contextRoot); >>> >>>context.setConfigurationClasses(new String[]{ >>>"org.mortbay.jetty.webapp.WebInfConfiguration", >>>"org.mortbay.jetty.plus.webapp.EnvConfiguration", >>>"org.mortbay.jetty.annotations.Configuration", >>>"org.mortbay.jetty.webapp.JettyWebXmlConfiguration", >>>"org.mortbay.jetty.webapp.TagLibConfiguration" >>>}); >>> >>>context.setExtractWAR(false); >>>context.setCopyWebDir(false); >>>context.setParentLoaderPriority(true); >>> >>>server.setHandler(context); >>> >>>server.start(); >>> >>>return server; >>>} >>> >>>public static void destroyServer(Server server) throws Exception { >>>if (server == null) return; >>>if (!server.isStopped()) { >>>server.stop(); >>>server.join(); >>>} >>>} >>> } >>> >>> >>> On 4 March 2010 11:58, Douglas Ferguson wrote: >>> I've been experimenting with this and have come to find out that the mvn jetty plugin is not compatible with projects that include jetty in their pom dependencies. Now I need to figure out a different way to start up jetty. I have a Start.java class that could start up jetty but i would need to figure out how to stop it. Also, I'm found some information online about a version cobertura plugin that had a seperate generate-report goal. Anybody know where I could locate this? D/ On Mar 4, 2010, at 4:05 AM, Brett Porter wrote: > On 04/03/2010, at 8:49 PM, Douglas Ferguson wrote: > >> Is there a clean way to start up jetty for the testing and then stopping git afterwards? >> >> I'd like to include my integration tests for my code coverage. >> >> I'd like to set my code coverage profile to only start up jetty after cobertura has instrumented the classes >> then shut it down after the tests complete. >> >> Could I just start up the jetty in process-test-classes and shut it down in prepare-package? > > Yep. > > http://github.com/brettporter/centrepoint/blob/master/centrepoint/modules/selenium-tests/pom.xml > > Bear in mind that if the tests fail, the "stop" won't be run, but normally they will shut down properly when Maven does anyway. > > - Brett > > -- > Brett Porter > br...@apache.org > http://brettporter.wordpress.com/ > > > > > > - > To unsubscribe, e-mail: users-unsubscr...@maven.apache.org > For additional commands, e-mail: users-h...@maven.apache.org > - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org >> >> >> - >> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org >> For additional commands, e-mail: users-h...@maven.apache.org >> >> > > - > To unsubscribe, e-mail: users-unsubscr...@maven.apache.org > For additional commands, e-mail: users-h...@maven.apache.org > --
Re: starting jetty during tests and stopping afterwards
If it takes a long time, why would you restart for each test? If you look at the link I sent, you'll see the instance is started only once per jvm by default. Kalle On Thu, Mar 4, 2010 at 10:35 AM, Douglas Ferguson wrote: > I have 20 tests and the number is growing. > > I don't want to start and stop jetty for every test, because hibernate and > guice intialize actually take a little bit of time. > Which would slow down the entire suite.. > > D/ > > > On Mar 4, 2010, at 12:17 PM, Kalle Korhonen wrote: > >> Why would you insist on starting it with mvn? How do you run the the >> same test in your IDE? Wouldn't it be easier to just use JettyHelper >> in your test? For another example of the same concept, perhaps a bit >> more evolved, see >> http://svn.codehaus.org/tynamo/trunk/tapestry-model/tapestry-model-test/src/main/java/org/tynamo/test/AbstractContainerTest.java >> (http://tynamo.org) >> >> Kalle >> >> >> On Thu, Mar 4, 2010 at 9:38 AM, Douglas Ferguson >> wrote: >>> Hmm.. But how would I start that and stop it with mvn? Looks like you'd >>> need to have a reference to the instantiated JettyHelp in order to stop it. >>> >>> D/ >>> >>> On Mar 4, 2010, at 6:07 AM, Stephen Connolly wrote: >>> public final class JettyHelper { private JettyHelper() { throw new IllegalAccessError("Utility class"); } public static Server createServer(int port, File warFile, String contextRoot) throws Exception { Server server = new Server(); Connector connector = new SelectChannelConnector(); connector.setPort(port); server.addConnector(connector); WebAppContext context = new WebAppContext(warFile.getAbsolutePath(), contextRoot); context.setConfigurationClasses(new String[]{ "org.mortbay.jetty.webapp.WebInfConfiguration", "org.mortbay.jetty.plus.webapp.EnvConfiguration", "org.mortbay.jetty.annotations.Configuration", "org.mortbay.jetty.webapp.JettyWebXmlConfiguration", "org.mortbay.jetty.webapp.TagLibConfiguration" }); context.setExtractWAR(false); context.setCopyWebDir(false); context.setParentLoaderPriority(true); server.setHandler(context); server.start(); return server; } public static void destroyServer(Server server) throws Exception { if (server == null) return; if (!server.isStopped()) { server.stop(); server.join(); } } } On 4 March 2010 11:58, Douglas Ferguson wrote: > I've been experimenting with this and have come to find out that the mvn > jetty plugin is not compatible with projects that include jetty in their > pom > dependencies. > > Now I need to figure out a different way to start up jetty. I have a > Start.java class that could start up jetty but i would need to figure out > how to stop it. > > Also, I'm found some information online about a version cobertura plugin > that had a seperate generate-report goal. Anybody know where I could > locate > this? > > D/ > > On Mar 4, 2010, at 4:05 AM, Brett Porter wrote: > >> On 04/03/2010, at 8:49 PM, Douglas Ferguson wrote: >> >>> Is there a clean way to start up jetty for the testing and then stopping > git afterwards? >>> >>> I'd like to include my integration tests for my code coverage. >>> >>> I'd like to set my code coverage profile to only start up jetty after > cobertura has instrumented the classes >>> then shut it down after the tests complete. >>> >>> Could I just start up the jetty in process-test-classes and shut it down > in prepare-package? >> >> Yep. >> >> > http://github.com/brettporter/centrepoint/blob/master/centrepoint/modules/selenium-tests/pom.xml >> >> Bear in mind that if the tests fail, the "stop" won't be run, but > normally they will shut down properly when Maven does anyway. >> >> - Brett >> >> -- >> Brett Porter >> br...@apache.org >> http://brettporter.wordpress.com/ >> >> >> >> >> >> - >> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org >> For additional commands, e-mail: users-h...@maven.apache.org >> > > > - > To unsubscribe, e-mail: users-unsubscr...@maven.apache.org > For additional commands, e-mail: users-h...@maven.apache.org > > >>> >>> >>> - >>> To unsubscribe, e-mail: users-unsubscr...@maven.apache.or
Re: starting jetty during tests and stopping afterwards
So how does the server get stopped? On Mar 4, 2010, at 12:46 PM, Kalle Korhonen wrote: > If it takes a long time, why would you restart for each test? If you > look at the link I sent, you'll see the instance is started only once > per jvm by default. > > Kalle > > > On Thu, Mar 4, 2010 at 10:35 AM, Douglas Ferguson > wrote: >> I have 20 tests and the number is growing. >> >> I don't want to start and stop jetty for every test, because hibernate and >> guice intialize actually take a little bit of time. >> Which would slow down the entire suite.. >> >> D/ >> >> >> On Mar 4, 2010, at 12:17 PM, Kalle Korhonen wrote: >> >>> Why would you insist on starting it with mvn? How do you run the the >>> same test in your IDE? Wouldn't it be easier to just use JettyHelper >>> in your test? For another example of the same concept, perhaps a bit >>> more evolved, see >>> http://svn.codehaus.org/tynamo/trunk/tapestry-model/tapestry-model-test/src/main/java/org/tynamo/test/AbstractContainerTest.java >>> (http://tynamo.org) >>> >>> Kalle >>> >>> >>> On Thu, Mar 4, 2010 at 9:38 AM, Douglas Ferguson >>> wrote: Hmm.. But how would I start that and stop it with mvn? Looks like you'd need to have a reference to the instantiated JettyHelp in order to stop it. D/ On Mar 4, 2010, at 6:07 AM, Stephen Connolly wrote: > public final class JettyHelper { > >private JettyHelper() { >throw new IllegalAccessError("Utility class"); >} > >public static Server createServer(int port, File warFile, String > contextRoot) throws Exception { > >Server server = new Server(); >Connector connector = new SelectChannelConnector(); >connector.setPort(port); >server.addConnector(connector); > >WebAppContext context = new > WebAppContext(warFile.getAbsolutePath(), > contextRoot); > >context.setConfigurationClasses(new String[]{ >"org.mortbay.jetty.webapp.WebInfConfiguration", >"org.mortbay.jetty.plus.webapp.EnvConfiguration", >"org.mortbay.jetty.annotations.Configuration", >"org.mortbay.jetty.webapp.JettyWebXmlConfiguration", >"org.mortbay.jetty.webapp.TagLibConfiguration" >}); > >context.setExtractWAR(false); >context.setCopyWebDir(false); >context.setParentLoaderPriority(true); > >server.setHandler(context); > >server.start(); > >return server; >} > >public static void destroyServer(Server server) throws Exception { >if (server == null) return; >if (!server.isStopped()) { >server.stop(); >server.join(); >} >} > } > > > On 4 March 2010 11:58, Douglas Ferguson > wrote: > >> I've been experimenting with this and have come to find out that the mvn >> jetty plugin is not compatible with projects that include jetty in their >> pom >> dependencies. >> >> Now I need to figure out a different way to start up jetty. I have a >> Start.java class that could start up jetty but i would need to figure out >> how to stop it. >> >> Also, I'm found some information online about a version cobertura plugin >> that had a seperate generate-report goal. Anybody know where I could >> locate >> this? >> >> D/ >> >> On Mar 4, 2010, at 4:05 AM, Brett Porter wrote: >> >>> On 04/03/2010, at 8:49 PM, Douglas Ferguson wrote: >>> Is there a clean way to start up jetty for the testing and then stopping >> git afterwards? I'd like to include my integration tests for my code coverage. I'd like to set my code coverage profile to only start up jetty after >> cobertura has instrumented the classes then shut it down after the tests complete. Could I just start up the jetty in process-test-classes and shut it down >> in prepare-package? >>> >>> Yep. >>> >>> >> http://github.com/brettporter/centrepoint/blob/master/centrepoint/modules/selenium-tests/pom.xml >>> >>> Bear in mind that if the tests fail, the "stop" won't be run, but >> normally they will shut down properly when Maven does anyway. >>> >>> - Brett >>> >>> -- >>> Brett Porter >>> br...@apache.org >>> http://brettporter.wordpress.com/ >>> >>> >>> >>> >>> >>> - >>> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org >>> For additional commands, e-mail: users-h...@maven.apache.org >>> >> >> >> -
Re: starting jetty during tests and stopping afterwards
On Thu, Mar 4, 2010 at 11:03 AM, Douglas Ferguson wrote: > So how does the server get stopped? Up to you, but typically when the JVM exits. Kalle > On Mar 4, 2010, at 12:46 PM, Kalle Korhonen wrote: > >> If it takes a long time, why would you restart for each test? If you >> look at the link I sent, you'll see the instance is started only once >> per jvm by default. >> >> Kalle >> >> >> On Thu, Mar 4, 2010 at 10:35 AM, Douglas Ferguson >> wrote: >>> I have 20 tests and the number is growing. >>> >>> I don't want to start and stop jetty for every test, because hibernate and >>> guice intialize actually take a little bit of time. >>> Which would slow down the entire suite.. >>> >>> D/ >>> >>> >>> On Mar 4, 2010, at 12:17 PM, Kalle Korhonen wrote: >>> Why would you insist on starting it with mvn? How do you run the the same test in your IDE? Wouldn't it be easier to just use JettyHelper in your test? For another example of the same concept, perhaps a bit more evolved, see http://svn.codehaus.org/tynamo/trunk/tapestry-model/tapestry-model-test/src/main/java/org/tynamo/test/AbstractContainerTest.java (http://tynamo.org) Kalle On Thu, Mar 4, 2010 at 9:38 AM, Douglas Ferguson wrote: > Hmm.. But how would I start that and stop it with mvn? Looks like you'd > need to have a reference to the instantiated JettyHelp in order to stop > it. > > D/ > > On Mar 4, 2010, at 6:07 AM, Stephen Connolly wrote: > >> public final class JettyHelper { >> >> private JettyHelper() { >> throw new IllegalAccessError("Utility class"); >> } >> >> public static Server createServer(int port, File warFile, String >> contextRoot) throws Exception { >> >> Server server = new Server(); >> Connector connector = new SelectChannelConnector(); >> connector.setPort(port); >> server.addConnector(connector); >> >> WebAppContext context = new >> WebAppContext(warFile.getAbsolutePath(), >> contextRoot); >> >> context.setConfigurationClasses(new String[]{ >> "org.mortbay.jetty.webapp.WebInfConfiguration", >> "org.mortbay.jetty.plus.webapp.EnvConfiguration", >> "org.mortbay.jetty.annotations.Configuration", >> "org.mortbay.jetty.webapp.JettyWebXmlConfiguration", >> "org.mortbay.jetty.webapp.TagLibConfiguration" >> }); >> >> context.setExtractWAR(false); >> context.setCopyWebDir(false); >> context.setParentLoaderPriority(true); >> >> server.setHandler(context); >> >> server.start(); >> >> return server; >> } >> >> public static void destroyServer(Server server) throws Exception { >> if (server == null) return; >> if (!server.isStopped()) { >> server.stop(); >> server.join(); >> } >> } >> } >> >> >> On 4 March 2010 11:58, Douglas Ferguson >> wrote: >> >>> I've been experimenting with this and have come to find out that the mvn >>> jetty plugin is not compatible with projects that include jetty in >>> their pom >>> dependencies. >>> >>> Now I need to figure out a different way to start up jetty. I have a >>> Start.java class that could start up jetty but i would need to figure >>> out >>> how to stop it. >>> >>> Also, I'm found some information online about a version cobertura plugin >>> that had a seperate generate-report goal. Anybody know where I could >>> locate >>> this? >>> >>> D/ >>> >>> On Mar 4, 2010, at 4:05 AM, Brett Porter wrote: >>> On 04/03/2010, at 8:49 PM, Douglas Ferguson wrote: > Is there a clean way to start up jetty for the testing and then > stopping >>> git afterwards? > > I'd like to include my integration tests for my code coverage. > > I'd like to set my code coverage profile to only start up jetty after >>> cobertura has instrumented the classes > then shut it down after the tests complete. > > Could I just start up the jetty in process-test-classes and shut it > down >>> in prepare-package? Yep. >>> http://github.com/brettporter/centrepoint/blob/master/centrepoint/modules/selenium-tests/pom.xml Bear in mind that if the tests fail, the "stop" won't be run, but >>> normally they will shut down properly when Maven does anyway. - Brett -- Brett Porter br...@apache.org http://brettporter.wordpress.com/ --
Re: starting jetty during tests and stopping afterwards
Wierd.. I was not seing that happen. Could it be that we have thread pools running? But i was testing it with eclipse. I wrapped the call to start with a main() and ran that from eclipse and it kept running.. D// On Mar 4, 2010, at 1:17 PM, Kalle Korhonen wrote: > On Thu, Mar 4, 2010 at 11:03 AM, Douglas Ferguson > wrote: >> So how does the server get stopped? > > Up to you, but typically when the JVM exits. > > Kalle > > >> On Mar 4, 2010, at 12:46 PM, Kalle Korhonen wrote: >> >>> If it takes a long time, why would you restart for each test? If you >>> look at the link I sent, you'll see the instance is started only once >>> per jvm by default. >>> >>> Kalle >>> >>> >>> On Thu, Mar 4, 2010 at 10:35 AM, Douglas Ferguson >>> wrote: I have 20 tests and the number is growing. I don't want to start and stop jetty for every test, because hibernate and guice intialize actually take a little bit of time. Which would slow down the entire suite.. D/ On Mar 4, 2010, at 12:17 PM, Kalle Korhonen wrote: > Why would you insist on starting it with mvn? How do you run the the > same test in your IDE? Wouldn't it be easier to just use JettyHelper > in your test? For another example of the same concept, perhaps a bit > more evolved, see > http://svn.codehaus.org/tynamo/trunk/tapestry-model/tapestry-model-test/src/main/java/org/tynamo/test/AbstractContainerTest.java > (http://tynamo.org) > > Kalle > > > On Thu, Mar 4, 2010 at 9:38 AM, Douglas Ferguson > wrote: >> Hmm.. But how would I start that and stop it with mvn? Looks like you'd >> need to have a reference to the instantiated JettyHelp in order to stop >> it. >> >> D/ >> >> On Mar 4, 2010, at 6:07 AM, Stephen Connolly wrote: >> >>> public final class JettyHelper { >>> >>>private JettyHelper() { >>>throw new IllegalAccessError("Utility class"); >>>} >>> >>>public static Server createServer(int port, File warFile, String >>> contextRoot) throws Exception { >>> >>>Server server = new Server(); >>>Connector connector = new SelectChannelConnector(); >>>connector.setPort(port); >>>server.addConnector(connector); >>> >>>WebAppContext context = new >>> WebAppContext(warFile.getAbsolutePath(), >>> contextRoot); >>> >>>context.setConfigurationClasses(new String[]{ >>>"org.mortbay.jetty.webapp.WebInfConfiguration", >>>"org.mortbay.jetty.plus.webapp.EnvConfiguration", >>>"org.mortbay.jetty.annotations.Configuration", >>>"org.mortbay.jetty.webapp.JettyWebXmlConfiguration", >>>"org.mortbay.jetty.webapp.TagLibConfiguration" >>>}); >>> >>>context.setExtractWAR(false); >>>context.setCopyWebDir(false); >>>context.setParentLoaderPriority(true); >>> >>>server.setHandler(context); >>> >>>server.start(); >>> >>>return server; >>>} >>> >>>public static void destroyServer(Server server) throws Exception { >>>if (server == null) return; >>>if (!server.isStopped()) { >>>server.stop(); >>>server.join(); >>>} >>>} >>> } >>> >>> >>> On 4 March 2010 11:58, Douglas Ferguson >>> wrote: >>> I've been experimenting with this and have come to find out that the mvn jetty plugin is not compatible with projects that include jetty in their pom dependencies. Now I need to figure out a different way to start up jetty. I have a Start.java class that could start up jetty but i would need to figure out how to stop it. Also, I'm found some information online about a version cobertura plugin that had a seperate generate-report goal. Anybody know where I could locate this? D/ On Mar 4, 2010, at 4:05 AM, Brett Porter wrote: > On 04/03/2010, at 8:49 PM, Douglas Ferguson wrote: > >> Is there a clean way to start up jetty for the testing and then >> stopping git afterwards? >> >> I'd like to include my integration tests for my code coverage. >> >> I'd like to set my code coverage profile to only start up jetty after cobertura has instrumented the classes >> then shut it down after the tests complete. >> >> Could I just start up the jetty in process-test-classes and shut it >> down in prepare-package? > > Yep. > > http://