Willem Jiang & Freeman Fang:

Your answers both work well. Thanks a lot.

> -----Origin -----
> Sender: Willem Jiang [mailto:[email protected]]
>Time: 2011年5月26日 15:48
>Receiver: [email protected]
> Subject: Re: Why cannot run all my CXF's spring test cases in mvn?
> 
> Because of the HTTP keep alive feature, if you close the socket and
> start a new socket which listen to the same port in the same process,
> you may face an issue that new start socket can't accept the request
> anymore.
> 
> Normally you can start the server before the test class is load and
> shutdown it after all the tests are finished.
> 
> And you need configure the surefile plugin to fork new process to the
test.
> 
>        <plugin>
>          <artifactId>maven-surefire-plugin</artifactId>
>          <configuration>
>            <forkMode>pertest</forkMode>
>            <childDelegation>false</childDelegation>
>            <useFile>true</useFile>
>            <systemPropertyVariables>
> 
> <java.util.logging.config.file>${basedir}/target/test-classes/logging.prop
> erties</java.u
> til.logging.config.file>
>            </systemPropertyVariables>
>          </configuration>
>        </plugin>
> 
> And CXF can allocate different port for the system test to leverage the
> running the system test in multiple threads which is a new feature of
> maven3.
> 
> 
> On 5/26/11 2:10 PM, Freeman Fang wrote:
> > Hi,
> >
> > I believe OS need some time to reclaim the port, that's why your test
> > failure if you run a bunch of tests together using same port.
> > In CXF we use dynamic ports for system tests, you may need take a look.
> >
> > Freeman
> > On 2011-5-26, at 下午1:06, ext2 wrote:
> >
> >> Hi:
> >>
> >> I wrote several test cases in my project. If I run them one by one,
> >> they are
> >> all ok; But if I using "mvn test" to run all test cases at once, there
> >> are
> >> some test case failure occasionally.
> >> Each test case will start a jaxw-ws service configured by spring and
> >> destroy
> >> it after test case end;
> >>
> >> I have tried to avoid such problem. it seems I must using different
http
> >> server port for different test case. But it is exhaust to assign
> >> different
> >> port for different test case.
> >>
> >> Does anyone know how to resolve such problem?
> >>
> >> By the way , I have try to find the answer by checking source code of
> >> CXF.
> >> And add some log in JettyHttpEngine.shutdown(). I am sure the created
> >> JettyHttpEngine have been shutdown correctly;
> >>
> >>
> >> The structure of my test cases are both like as following:
> >>
> >> 1) using a spring xml to configure a jaxws service: etc
> >> <jaxws:endpoint id="mtomBean" implementor=".... "
> >> address="http://localhost:9000/service/mtomRequest64Response64"; ...>
> >>
> >> 2) start the spring configured service at TestCase's setup() procedure:
> >> @Before
> >> void setup(){
> >> ClassPathXmlApplicationContext context = new
> >> ClassPathXmlApplicationContext(
> >> "mtom/mtom-server-bean.xml");
> >> context.start();
> >> }
> >>
> >> 3) stop the spring configured service at TestCase's cleanup()
procedure:
> >> {
> >> context.destroy(); //I also tried context.stop();
> >> }
> >>
> >> 4) do the client's invoke and assertions in TestCase's testXXX case;
> >>
> >>
> >>
> >
> > ---------------------------------------------
> > Freeman Fang
> >
> > FuseSource
> > Email:[email protected]
> > Web: fusesource.com
> > Twitter: freemanfang
> > Blog: http://freemanfang.blogspot.com
> > Connect at CamelOne May 24-26
> > The Open Source Integration Conference
> >
> >
> >
> >
> >
> >
> >
> >
> >
> 
> 
> --
> Willem
> ----------------------------------
> FuseSource
> Web: http://www.fusesource.com
> Blog:    http://willemjiang.blogspot.com (English)
>           http://jnn.javaeye.com (Chinese)
> Twitter: willemjiang
> 
> Connect at CamelOne May 24-26
> The Open Source Integration Conference
> http://camelone.com


Reply via email to