use of com.weibo.api.motan.core.extension.ExtensionLoader in project motan by weibocom.
the class BaseTest method before.
@Before
public void before() {
mockery = new JUnit4Mockery() {
{
setImposteriser(ClassImposteriser.INSTANCE);
}
};
final Server mockServer = mockery.mock(Server.class);
final Client mockClient = mockery.mock(Client.class);
mockery.checking(new Expectations() {
{
allowing(mockClient).open();
will(returnValue(true));
allowing(mockClient).close();
will(returnValue(null));
allowing(mockClient).isAvailable();
will(returnValue(true));
allowing(mockServer).open();
will(returnValue(true));
allowing(mockServer).close();
will(returnValue(null));
allowing(mockServer).isAvailable();
will(returnValue(true));
}
});
ExtensionLoader loader = ExtensionLoader.getExtensionLoader(EndpointFactory.class);
endpointFactory = (MockEndpointFactory) loader.getExtension("mockEndpoint");
if (endpointFactory == null) {
loader.addExtensionClass(MockEndpointFactory.class);
endpointFactory = (MockEndpointFactory) loader.getExtension("mockEndpoint");
}
loader = ExtensionLoader.getExtensionLoader(RegistryFactory.class);
MockRegistryFactory registryFactory = (MockRegistryFactory) loader.getExtension("mockRegistry");
if (registryFactory == null) {
loader.addExtensionClass(MockRegistryFactory.class);
}
endpointFactory.setClient(mockClient);
endpointFactory.setServer(mockServer);
cp = new ClassPathXmlApplicationContext("classpath:schemaTestContext.xml");
}
Aggregations