No maven. These are tests in my product, run from Eclipse or ant.

> -----Original Message-----
> From: Freeman Fang [mailto:[EMAIL PROTECTED]
> Sent: Monday, October 01, 2007 11:48 AM
> To: [email protected]
> Subject: Re: Spring, bus, confusion
> 
> Hi Benson,
> 
> I assume you use mvn to run the test, so would you please check your
> configuration of maven-surefire-plugin, ensure that the <forkmode>
> property
> is "pertest".
> Best Regards
> Freeman
> 
> 
> On 10/1/07, Benson Margulies <[EMAIL PROTECTED]> wrote:
> >
> > The server's list of handlers still has the extra handler. Did you
look
> > at the source code I sent? The @Before method inserts an extra
handler
> > into the server. The @After calls bus.shutdown.
> >
> > The next time we run the @Before, we should be restarting from
complete
> > zero, we are rereading the beans into a new app context. Yet, the
server
> > on the bus still somehow has the extra handler.
> >
> > > -----Original Message-----
> > > From: Willem2 [mailto:[EMAIL PROTECTED]
> > > Sent: Monday, October 01, 2007 11:32 AM
> > > To: [email protected]
> > > Subject: RE: Spring, bus, confusion
> > >
> > >
> > > What do you mean the server's configuration is there?
> > >
> > > Do you mean the jetty server is still there ?
> > >
> > > Willem.
> > >
> > >
> > > bmargulies wrote:
> > > >
> > > > I tried that. I still found my configuration changes to the
server
> > > > 'already present' when I create the next application context.
> > > >
> > > >> -----Original Message-----
> > > >> From: Willem2 [mailto:[EMAIL PROTECTED]
> > > >> Sent: Monday, October 01, 2007 9:11 AM
> > > >> To: [email protected]
> > > >> Subject: Re: Spring, bus, confusion
> > > >>
> > > >>
> > > >> Hi Benson,
> > > >>
> > > >> You can call bus.shutdown(true) in @After to tear down the
server
> > and
> > > > the
> > > >> jetty engine.
> > > >>
> > > >>
> > > >> Willem.
> > > >>
> > > >>
> > > >> bmargulies wrote:
> > > >> >
> > > >> > Please forgive me for pasting a lot of code into here.
> > > >> >
> > > >> > I'm trying to set up a unit test framework where the fixture
sets
> > up
> > > >> > jetty with an endpoint and some static content. So, as you
will
> > see,
> > > > I
> > > >> > have an @Before that sets everything up, and an @After that
tries
> > to
> > > >> > tear everything down.
> > > >> >
> > > >> > However, when the @Before runs the second time, things sure
look
> > as
> > > > if
> > > >> > they have all hung around from the first time around.
> > > >> >
> > > >> > I bet that there's something simple about the bus that I'm
> > missing,
> > > >> > namely, that the cxf bus exists independently of my app
context,
> > and
> > > > I
> > > >> > have to \do something/ to tear \it/ down.
> > > >> >
> > > >> >
> > > >> >
> > > >> >
> > > >> >
> > > >> > package com.basistech.ws;
> > > >> >
> > > >> > import java.io.File;
> > > >> > import java.net.URL;
> > > >> >
> > > >> > import org.apache.cxf.Bus;
> > > >> > import org.apache.cxf.endpoint.ServerImpl;
> > > >> > import org.apache.cxf.endpoint.ServerRegistry;
> > > >> > import
org.apache.cxf.transport.http_jetty.JettyHTTPDestination;
> > > >> > import
org.apache.cxf.transport.http_jetty.JettyHTTPServerEngine;
> > > >> > import org.junit.After;
> > > >> > import org.junit.Before;
> > > >> > import org.mortbay.jetty.Handler;
> > > >> > import org.mortbay.jetty.Server;
> > > >> > import org.mortbay.jetty.handler.ContextHandlerCollection;
> > > >> > import org.mortbay.jetty.handler.HandlerList;
> > > >> > import org.mortbay.jetty.handler.ResourceHandler;
> > > >> > import org.mortbay.resource.FileResource;
> > > >> > import
> > > > org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
> > > >> > import
> > > > org.springframework.context.support.GenericApplicationContext;
> > > >> > import org.springframework.core.io.ClassPathResource;
> > > >> > import org.springframework.core.io.Resource;
> > > >> >
> > > >> > /**
> > > >> >  * Class used to launch a CXF/jetty web service using the
> > embedded
> > > > jetty
> > > >> > in CXF.
> > > >> >  *
> > > >> >  */
> > > >> > public abstract class AbstractTestService {
> > > >> >
> > > >> >     protected abstract Resource getServiceDefinitionBeans();
> > > >> >     protected abstract String getStaticContentPath();
> > > >> >     protected GenericApplicationContext applicationContext;
> > > >> >     protected Bus bus;
> > > >> >
> > > >> >     private void readBeans(Resource beanResource) {
> > > >> >         XmlBeanDefinitionReader reader = new
> > > >> > XmlBeanDefinitionReader(applicationContext);
> > > >> >         reader.loadBeanDefinitions(beanResource);
> > > >> >     }
> > > >> >
> > > >> >     @Before
> > > >> >     public void launchService() throws Exception {
> > > >> >         applicationContext = new GenericApplicationContext();
> > > >> >         readBeans(new
ClassPathResource("META-INF/cxf/cxf.xml"));
> > > >> >         readBeans(new
> > > >> > ClassPathResource("META-INF/cxf/cxf-extension-soap.xml"));
> > > >> >         readBeans(new
> > > >> > ClassPathResource("META-INF/cxf/cxf-extension-http.xml"));
> > > >> >         readBeans(new
> > > >> >
ClassPathResource("META-INF/cxf/cxf-extension-http-jetty.xml"));
> > > >> >         readBeans(getServiceDefinitionBeans());
> > > >> >         applicationContext.refresh();
> > > >> >
> > > >> >         bus = (Bus)applicationContext.getBean("cxf");
> > > >> >         ServerRegistry sr=
> > bus.getExtension(ServerRegistry.class);
> > > >> >         ServerImpl si = (ServerImpl) sr.getServers().get(0);
> > > >> >         JettyHTTPDestination jhd =
> > > >> > (JettyHTTPDestination)si.getDestination();
> > > >> >         JettyHTTPServerEngine engine =
(JettyHTTPServerEngine)
> > > >> > jhd.getEngine();
> > > >> >         Server server = engine.getServer();
> > > >> >         Handler serverHandler = server.getHandler();
> > > >> >         ContextHandlerCollection contextHandlerCollection =
> > > >> > (ContextHandlerCollection)serverHandler;
> > > >> >         HandlerList handlerList = new HandlerList();
> > > >> >         ResourceHandler resourceHandler = new
ResourceHandler();
> > > >> >         handlerList.addHandler(resourceHandler);
> > > >> >         handlerList.addHandler(contextHandlerCollection);
> > > >> >         server.setHandler(handlerList);
> > > >> >         handlerList.start();
> > > >> >         File staticContentFile = new
> > File(getStaticContentPath());
> > > >> >         URL targetURL = new URL("file://" +
> > > >> > staticContentFile.getCanonicalPath());
> > > >> >         FileResource fileResource = new
FileResource(targetURL);
> > > >> >         resourceHandler.setBaseResource(fileResource);
> > > >> >     }
> > > >> >
> > > >> >     @After
> > > >> >     public void shutdownService() throws Exception {
> > > >> >         bus = (Bus)applicationContext.getBean("cxf");
> > > >> >         ServerRegistry sr =
> > bus.getExtension(ServerRegistry.class);
> > > >> >         ServerImpl si = (ServerImpl) sr.getServers().get(0);
> > > >> >         JettyHTTPDestination jhd =
> > > >> > (JettyHTTPDestination)si.getDestination();
> > > >> >         JettyHTTPServerEngine e = (JettyHTTPServerEngine)
> > > >> > jhd.getEngine();
> > > >> >         e.getServer().stop();
> > > >> >         applicationContext.destroy();
> > > >> >     }
> > > >> >
> > > >> > }
> > > >> >
> > > >> >
> > > >>
> > > >> --
> > > >> View this message in context:
> > http://www.nabble.com/Spring%2C-bus%2C-
> > > >> confusion-tf4545841.html#a12978917
> > > >> Sent from the cxf-user mailing list archive at Nabble.com.
> > > >
> > > >
> > > >
> > >
> > > --
> > > View this message in context:
http://www.nabble.com/Spring%2C-bus%2C-
> > > confusion-tf4545841.html#a12981449
> > > Sent from the cxf-user mailing list archive at Nabble.com.
> >
> >

Reply via email to