use of org.apache.dubbo.rpc.Invocation in project dubbo by alibaba.
the class ExpiringCacheFactoryTest method constructCache.
@Override
protected Cache constructCache() {
URL url = URL.valueOf(EXPIRING_CACHE_URL);
Invocation invocation = new RpcInvocation();
return getCacheFactory().getCache(url, invocation);
}
use of org.apache.dubbo.rpc.Invocation in project dubbo by alibaba.
the class AbstractCacheFactoryTest method constructCache.
protected Cache constructCache() {
URL url = URL.valueOf("test://test:11/test?cache=lru");
Invocation invocation = new RpcInvocation();
return getCacheFactory().getCache(url, invocation);
}
use of org.apache.dubbo.rpc.Invocation in project dubbo by alibaba.
the class AccessLogFilterTest method testInvokeException.
// Test filter won't throw an exception
@Test
public void testInvokeException() {
Invoker<AccessLogFilterTest> invoker = new MyInvoker<AccessLogFilterTest>(null);
Invocation invocation = new MockInvocation();
LogUtil.start();
accessLogFilter.invoke(invoker, invocation);
assertEquals(1, LogUtil.findMessage("Exception in AccessLogFilter of service"));
LogUtil.stop();
DubboAppender.clear();
}
use of org.apache.dubbo.rpc.Invocation in project dubbo by alibaba.
the class AccessLogFilterTest method testDefault.
// TODO how to assert thread action
@Test
@SuppressWarnings("unchecked")
public void testDefault() throws NoSuchFieldException, IllegalAccessException {
URL url = URL.valueOf("test://test:11/test?accesslog=true&group=dubbo&version=1.1");
Invoker<AccessLogFilterTest> invoker = new MyInvoker<AccessLogFilterTest>(url);
Invocation invocation = new MockInvocation();
Field field = AccessLogFilter.class.getDeclaredField("LOG_ENTRIES");
ReflectUtils.makeAccessible(field);
assertTrue(((Map) field.get(AccessLogFilter.class)).isEmpty());
accessLogFilter.invoke(invoker, invocation);
Map<String, Queue<AccessLogData>> logs = (Map<String, Queue<AccessLogData>>) field.get(AccessLogFilter.class);
assertFalse(logs.isEmpty());
assertFalse(logs.get("true").isEmpty());
AccessLogData log = logs.get("true").iterator().next();
assertEquals("org.apache.dubbo.rpc.support.DemoService", log.getServiceName());
}
use of org.apache.dubbo.rpc.Invocation in project dubbo by alibaba.
the class ClassLoaderFilterTest method testInvoke.
@Test
public void testInvoke() throws Exception {
URL url = URL.valueOf("test://test:11/test?accesslog=true&group=dubbo&version=1.1");
String path = DemoService.class.getResource("/").getPath();
final URLClassLoader cl = new URLClassLoader(new java.net.URL[] { new java.net.URL("file:" + path) }) {
@Override
public Class<?> loadClass(String name) throws ClassNotFoundException {
try {
return findClass(name);
} catch (ClassNotFoundException e) {
return super.loadClass(name);
}
}
};
final Class<?> clazz = cl.loadClass(DemoService.class.getCanonicalName());
Invoker invoker = new MyInvoker(url) {
@Override
public Class getInterface() {
return clazz;
}
@Override
public Result invoke(Invocation invocation) throws RpcException {
Assertions.assertEquals(cl, Thread.currentThread().getContextClassLoader());
return null;
}
};
Invocation invocation = Mockito.mock(Invocation.class);
classLoaderFilter.invoke(invoker, invocation);
}
Aggregations