Search in sources :

Example 1 with ExtensionLoader

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");
}
Also used : Expectations(org.jmock.Expectations) RegistryFactory(com.weibo.api.motan.registry.RegistryFactory) JUnit4Mockery(org.jmock.integration.junit4.JUnit4Mockery) Server(com.weibo.api.motan.transport.Server) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) Client(com.weibo.api.motan.transport.Client) ExtensionLoader(com.weibo.api.motan.core.extension.ExtensionLoader) Before(org.junit.Before)

Aggregations

ExtensionLoader (com.weibo.api.motan.core.extension.ExtensionLoader)1 RegistryFactory (com.weibo.api.motan.registry.RegistryFactory)1 Client (com.weibo.api.motan.transport.Client)1 Server (com.weibo.api.motan.transport.Server)1 Expectations (org.jmock.Expectations)1 JUnit4Mockery (org.jmock.integration.junit4.JUnit4Mockery)1 Before (org.junit.Before)1 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)1