Sorry if I wasn't clear, but I tried without
server.getThreadPool().join(), and even if it works with junit eclipse
module, it doesn't work with Maven.
Thanks for the site, but I already read it, and it wasn't as clear as
your short exemple.
Jan Bartel a écrit :
Julien,
Sorry, my mistake. You don't need the server.getThreadPool().join().
Just get rid of it and things should work fine.
BTW: If you want JSP support you'll also need to add a
<scope>test</scope> dependency for the version of jsp you want to
support: 2.0 or 2.1. So you'll need a dependency for either
groupId=org.mortbay.jetty artifactId=jsp-2.0 or
groupId=org.mortbay.jetty artifactId=jsp-2.1
Oh, and by the way, there is this kind of info on the jetty site:
http://docs.codehaus.org/display/JETTY/Embedding+Jetty
regards
Jan
Julien Henry wrote:
Thanks for this example. It's exactly what I hoped to find on Jetty
website.
But I first tried to run the tests with Eclipse, and the process
hangs indefinitly on "server.getThreadPool().join(); "
I tried to remove this line, and tests are now running fine under
eclipse.
But with Maven, I doesn't work. I can see :
-------------------------------------------------------
T E S T S
-------------------------------------------------------
[surefire] Running net.sourceforge.jwebunit.AllTestsHtmlUnit
:INFO: Logging to STDERR via org.mortbay.log.StdErrLog
:INFO: NO JSP Support for /jwebunit, did not find
org.apache.jasper.servlet.JspServlet
:INFO: Started SelectChannelConnector @ 0.0.0.0:8082
and the only way to stop this is to press [Ctrl]+[C]
:INFO: Shutdown hook executing
:INFO: Shutdown hook complete
Terminer le programme de commandes (O/N) ? o
How can I make the tests running with Maven ?
Thanks
Julien
Jan Bartel a écrit :
Julien,
You're not starting jetty6 correctly in the JettySetup setup() method.
You need to do:
Server server = new Server();
XmlConfiguration xmlConfiguration = new XmlConfiguration(jettyConfig);
xmlConfiguration.configure(server);
server.start();
server.getThreadPool().join();
Instead of running jetty once for all the test cases, you could do a
startup and shutdown of Jetty in the individual TestCase setUp()
and tearDown() methods, and have the surefire plugin run **/*Test.java
cheers
Jan
Julien Henry wrote:
Hi Jan,
Here is currently how it works. I have many JUnit tests. These
tests are grouped in a test suite called AllTests.java this way :
public class AllTests extends TestSuite {
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(NavigationTest.class);
suite.addTestSuite(WebAssertionsTest.class);
....
return new JettySetup(suite);
}
public static void main(String[] args) {
junit.textui.TestRunner.run(suite());
}
}
JettySetup is used to launch Jetty only one time before all tests,
and to close it after :
public class JettySetup extends TestSetup {
private Server jettyServer = null;
public void setUp() {
try {
URL jettyConfig = JettySetup.class
.getResource("/jetty-test-config.xml");
if(jettyConfig==null) {
fail("Unable to locate jetty-test-config.xml on the
classpath");
}
jettyServer = new Server(jettyConfig);
jettyServer.start();
} catch (Exception e) {
e.printStackTrace();
fail("Could not start the Jetty server: " + e);
}
}
public void tearDown() {
try {
jettyServer.stop();
} catch (InterruptedException e) {
e.printStackTrace();
fail("Jetty server was interrupted: " + e);
}
}
}
With Maven 2, I only select AllTests as test to be launched :
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/AllTests.java</include>
</includes>
</configuration>
</plugin>
But I see a few drawbacks to this configuration :
- I don't have the detail of each test in Maven report (due to
Surefire bug I think) :
>> [INFO] Generate "Maven Surefire Report" report.
>> java.lang.NumberFormatException: For input string: "25,814"
>> at
org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:691)
>> ...
>> java.lang.NullPointerException
>> at
org.codehaus.mojo.surefire.SurefireReportGenerator.constructTestCasesSection(SurefireReportGenerator.java:344)
- I would like to run all tests 2 times, with a different
parameter, but without restarting Jetty. And if I can have a clear
report that show the number of success/failure for each value of
the parameter, it would be perfect.
Jan Bartel a écrit :
Julien,
Embedding Jetty6 is pretty simple. The jetty.xml config file is
written
in a straightforward mapping from the java API to xml syntax.
There is the
beginnings of a guide to embedding jetty also on the wiki at:
http://docs.codehaus.org/display/JETTY/Embedding+Jetty
Jetty is often used in the unit tests of other projects - a jetty
Server
instance is started in the test setup and stopped in the test
teardown.
However, if you want to use the plugin instead, you simply include
the relevant lines into your pom.xml file, and invoke it:
mvn jetty6:run
When you want to stop it, you <cntrl-c> it.
There is all the information on how to configure and run the plugin
here:
http://jetty.mortbay.org/jetty6/maven-plugin/index.html
cheers
Jan
Julien Henry wrote:
Hi Jan,
I tried to migrate to Jetty 6, but there are too few doc about
how to use embedded Jetty. I discovered that a Jetty6 plugin
exists, and I think it could be a good thing to start jetty
before the JUnit tests, and to stop Jetty after, because it
exactly what I want. Do you know a simple way to do this ?
Thanks
Julien
Jan Bartel a écrit :
Hi Julien.
Jetty 5.x is built by ant, but the artifacts are made available on
ibiblio. The jetty5.x series, whilst the current stable series is
about to be superceded by the 6.x series.
Jetty 6.x is built by maven2 and has full poms with dependencies
listed which maven2 will transitively resolve for you.
I suggest you switch to jetty 6.x as 1) it is built by maven2 and
2) anyway has many many less dependencies.
cheers
Jan
Julien Henry wrote:
Hi,
I'm using Jetty to test my project. I have this in my pom (I
use JSP) :
<dependency>
<groupId>jetty</groupId>
<artifactId>org.mortbay.jetty</artifactId>
<version>5.1.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jetty</groupId>
<artifactId>jasper-runtime</artifactId>
<version>4.2.20RC0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jetty</groupId>
<artifactId>jasper-compiler</artifactId>
<version>4.2.20RC0</version>
<scope>test</scope>
</dependency>
But the server can't be launched. I discovered that Jetty need
org.apache.commons-logging. So I added :
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.0.4</version>
<scope>test</scope>
</dependency>
But why don't put commons-logging as a dependency of Jetty in
the pom on ibiblio ?
Thanks
Julien
This message contains information that may be privileged or
confidential and is the property of the Capgemini Group. It is
intended only for the person to whom it is addressed. If you
are not the intended recipient, you are not authorized to read,
print, retain, copy, disseminate, distribute, or use this
message or any part thereof. If you receive this message in
error, please notify the sender immediately and delete all
copies of this message.
---------------------------------------------------------------------
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]
---------------------------------------------------------------------
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]
--
_________________________________________________________________________
Julien HENRY | **Capgemini Sud **| Nice
www.fr.capgemini.com <http://www.capgemini.com/>
Porte de l’Arénas – Entrée B | 455 Promenade des Anglais | 06200 Nice
**Join the Collaborative Business Experience**** **
_________________________________________________________________________
This message contains information that may be privileged or confidential and is
the property of the Capgemini Group. It is intended only for the person to whom
it is addressed. If you are not the intended recipient, you are not authorized
to read, print, retain, copy, disseminate, distribute, or use this message or
any part thereof. If you receive this message in error, please notify the
sender immediately and delete all copies of this message.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]