package tests.jfun.yan.xfire;
import java.io.IOException;
import jfun.util.ClassLoaderUtils;
import jfun.yan.Container;
import jfun.yan.xml.NutsProcessor;
import junit.framework.TestSuite;
import org.codehaus.xfire.XFire;
import org.codehaus.xfire.aegis.AbstractXFireAegisTest;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.service.ServiceFactory;
import org.codehaus.xfire.service.ServiceRegistry;
public class EchoServiceTestCase
extends AbstractXFireAegisTest
{
public static TestSuite suite(){
return new TestSuite(EchoServiceTestCase.class);
}
private Container yan;
public void setUp()
throws Exception
{
yan = createContainer();
super.setUp();
}
protected Container getContainer()
{
return yan;
}
public ServiceFactory getServiceFactory()
{
return (ServiceFactory) yan.getInstance("xfire.serviceFactory");
}
protected XFire getXFire()
{
return (XFire) yan.getInstance("xfire");
}
protected Object getInstance(String id)
{
return yan.getInstance(id);
}
public void testXfireIntegration()
throws Exception
{
Container yan = getContainer();
assertNotNull(yan.getInstance("xfire.serviceFactory"));
Service service = (Service)yan.getInstance("echo");
assertNotNull(service);
assertEquals(org.codehaus.xfire.test.Echo.class,
service.getServiceInfo().getServiceClass());
assertEquals("echo", service.getName().getLocalPart());
ServiceRegistry reg = (ServiceRegistry) yan.getInstance("xfire.serviceRegistry");
}
protected Container createContainer()
throws IOException{
NutsProcessor processor = new NutsProcessor(
ClassLoaderUtils.guessClassLoader(getClass().getClassLoader()));
processor.processResource("jfun/yan/xfire/xfireXmlBeans.xml");
processor.processResource("tests/jfun/yan/xfire/echo.xml");
processor.preInstantiate();
return processor.getContainer();
}
}