use of com.alipay.sofa.runtime.test.beans.service.DefaultSampleService in project sofa-boot by sofastack.
the class ClientFactoryAwareBean method afterPropertiesSet.
@Override
public void afterPropertiesSet() {
ServiceParam serviceParam = new ServiceParam();
serviceParam.setInstance(new DefaultSampleService(ClientFactory.class.getName()));
serviceParam.setInterfaceType(SampleService.class);
serviceParam.setUniqueId("clientFactory");
clientFactory.getClient(ServiceClient.class).service(serviceParam);
}
use of com.alipay.sofa.runtime.test.beans.service.DefaultSampleService in project sofa-boot by sofastack.
the class ClientFactoryTest method testWithBindingParam.
/**
* test WithBindingParam in ReferenceClientImpl and ServiceClientImpl
*/
@Test
public void testWithBindingParam() {
JvmBindingParam jvmBindingParam = new JvmBindingParam();
jvmBindingParam.setSerialize(true);
ServiceParam serviceParam = new ServiceParam();
serviceParam.setInstance(new DefaultSampleService("WithBindingParam"));
serviceParam.setInterfaceType(SampleService.class);
serviceParam.setUniqueId("withBindingParam");
serviceParam.addBindingParam(jvmBindingParam);
serviceClient.service(serviceParam);
try {
Thread.sleep(2000);
} catch (Exception e) {
// ignore
}
ReferenceParam<SampleService> referenceParam = new ReferenceParam<>();
referenceParam.setInterfaceType(SampleService.class);
referenceParam.setUniqueId("withBindingParam");
referenceParam.setBindingParam(jvmBindingParam);
SampleService service = referenceClient.reference(referenceParam);
Assert.assertNotNull(service);
Assert.assertEquals("WithBindingParam", service.service());
}
use of com.alipay.sofa.runtime.test.beans.service.DefaultSampleService in project sofa-boot by alipay.
the class ClientFactoryAwareBean method afterPropertiesSet.
@Override
public void afterPropertiesSet() {
ServiceParam serviceParam = new ServiceParam();
serviceParam.setInstance(new DefaultSampleService(ClientFactory.class.getName()));
serviceParam.setInterfaceType(SampleService.class);
serviceParam.setUniqueId("clientFactory");
clientFactory.getClient(ServiceClient.class).service(serviceParam);
}
use of com.alipay.sofa.runtime.test.beans.service.DefaultSampleService in project sofa-boot by alipay.
the class ClientFactoryTest method testWithBindingParam.
/**
* test WithBindingParam in ReferenceClientImpl and ServiceClientImpl
*/
@Test
public void testWithBindingParam() {
JvmBindingParam jvmBindingParam = new JvmBindingParam();
jvmBindingParam.setSerialize(true);
ServiceParam serviceParam = new ServiceParam();
serviceParam.setInstance(new DefaultSampleService("WithBindingParam"));
serviceParam.setInterfaceType(SampleService.class);
serviceParam.setUniqueId("withBindingParam");
serviceParam.addBindingParam(jvmBindingParam);
serviceClient.service(serviceParam);
try {
Thread.sleep(2000);
} catch (Exception e) {
// ignore
}
ReferenceParam<SampleService> referenceParam = new ReferenceParam<>();
referenceParam.setInterfaceType(SampleService.class);
referenceParam.setUniqueId("withBindingParam");
referenceParam.setBindingParam(jvmBindingParam);
SampleService service = referenceClient.reference(referenceParam);
Assert.assertNotNull(service);
Assert.assertEquals("WithBindingParam", service.service());
}
Aggregations