use of com.alipay.sofa.rpc.boot.runtime.binding.RpcBinding in project sofa-boot by sofastack.
the class RpcBindingConverter method convert.
/**
* convert {@link RpcBindingParam} to concrete {@link RpcBinding}
*
* @param bindingParam binding parameter
* @param bindingConverterContext binding converter context
* @return RpcBinding Object
*/
@Override
public RpcBinding convert(RpcBindingParam bindingParam, BindingConverterContext bindingConverterContext) {
RpcBinding binding = createRpcBinding(bindingParam, bindingConverterContext.getApplicationContext(), bindingConverterContext.isInBinding());
setCallback(bindingParam, bindingConverterContext);
binding.setAppName(bindingConverterContext.getAppName());
binding.setBeanId(bindingConverterContext.getBeanId());
return binding;
}
use of com.alipay.sofa.rpc.boot.runtime.binding.RpcBinding in project sofa-boot by sofastack.
the class XsdTimeoutTest method testBindingMethod.
/**
* @see RpcBindingConverter#parseMethod
*/
@Test
public void testBindingMethod() {
// service
ServiceComponent component = (ServiceComponent) sofaRuntimeContext.getComponentManager().getComponentInfo(new ComponentName(ServiceComponent.SERVICE_COMPONENT_TYPE, MethodElementInterface.class.getName()));
RpcBinding binding = (RpcBinding) component.getService().getBinding(RpcBindingType.BOLT_BINDING_TYPE);
Assert.assertEquals(1, binding.getRpcBindingParam().getMethodInfos().size());
Assert.assertEquals("service", binding.getRpcBindingParam().getMethodInfos().get(0).getName());
Assert.assertEquals(10000, binding.getRpcBindingParam().getMethodInfos().get(0).getTimeout().intValue());
// reference
Collection<ComponentInfo> componentInfos = sofaRuntimeContext.getComponentManager().getComponentInfosByType(ReferenceComponent.REFERENCE_COMPONENT_TYPE);
for (ComponentInfo componentInfo : componentInfos) {
if (componentInfo instanceof ReferenceComponent) {
ReferenceComponent referenceComponent = (ReferenceComponent) componentInfo;
if (referenceComponent.getReference().getInterfaceType().equals(MethodElementInterface.class)) {
RpcBinding refBinding = (RpcBinding) referenceComponent.getReference().getBinding(RpcBindingType.BOLT_BINDING_TYPE);
Assert.assertEquals(1, refBinding.getRpcBindingParam().getMethodInfos().size());
Assert.assertEquals("service", refBinding.getRpcBindingParam().getMethodInfos().get(0).getName());
}
}
}
}
use of com.alipay.sofa.rpc.boot.runtime.binding.RpcBinding in project sofa-boot by sofastack.
the class XsdTimeoutTest method testServiceTimeout.
@Test
public void testServiceTimeout() {
ServiceComponent component = (ServiceComponent) sofaRuntimeContext.getComponentManager().getComponentInfo(new ComponentName(ServiceComponent.SERVICE_COMPONENT_TYPE, WhateverInterface.class.getName()));
RpcBinding binding = (RpcBinding) component.getService().getBinding(RpcBindingType.BOLT_BINDING_TYPE);
Assert.assertEquals((long) binding.getRpcBindingParam().getTimeout(), 10000);
}
use of com.alipay.sofa.rpc.boot.runtime.binding.RpcBinding in project sofa-boot by sofastack.
the class MockBeanConfigTest method testEmptyMockBean.
@Test
public void testEmptyMockBean() {
RpcBindingParam rpcBindingParam = new BoltBindingParam();
RpcBinding rpcBinding = new BoltBinding(rpcBindingParam, null, true);
try {
consumerConfigHelper.getMockRef(rpcBinding, null);
Assert.fail();
} catch (IllegalArgumentException e) {
// success;
}
}
use of com.alipay.sofa.rpc.boot.runtime.binding.RpcBinding in project sofa-boot by alipay.
the class RpcBindingConverter method convert.
/**
* convert {@link RpcBindingParam} to concrete {@link RpcBinding}
*
* @param bindingParam binding parameter
* @param bindingConverterContext binding converter context
* @return RpcBinding Object
*/
@Override
public RpcBinding convert(RpcBindingParam bindingParam, BindingConverterContext bindingConverterContext) {
RpcBinding binding = createRpcBinding(bindingParam, bindingConverterContext.getApplicationContext(), bindingConverterContext.isInBinding());
setCallback(bindingParam, bindingConverterContext);
binding.setAppName(bindingConverterContext.getAppName());
binding.setBeanId(bindingConverterContext.getBeanId());
return binding;
}
Aggregations