Search in sources :

Example 1 with HelloService

use of org.apache.dubbo.config.spring.api.HelloService in project dubbo by alibaba.

the class ConfigTest method testServiceAnnotation.

@Test
public void testServiceAnnotation() {
    AnnotationConfigApplicationContext providerContext = new AnnotationConfigApplicationContext();
    providerContext.register(ProviderConfiguration.class);
    providerContext.refresh();
    ReferenceConfig<HelloService> reference = new ReferenceConfig<HelloService>();
    reference.setRegistry(new RegistryConfig(RegistryConfig.NO_AVAILABLE));
    reference.setInterface(HelloService.class);
    reference.setUrl("dubbo://127.0.0.1:12345");
    DubboBootstrap bootstrap = DubboBootstrap.getInstance().application(new ApplicationConfig("consumer")).reference(reference).start();
    HelloService helloService = bootstrap.getCache().get(reference);
    String hello = helloService.sayHello("hello");
    assertEquals("Hello, hello", hello);
}
Also used : RegistryConfig(org.apache.dubbo.config.RegistryConfig) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) ReferenceConfig(org.apache.dubbo.config.ReferenceConfig) HelloService(org.apache.dubbo.config.spring.api.HelloService) DubboBootstrap(org.apache.dubbo.config.bootstrap.DubboBootstrap) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.jupiter.api.Test)

Example 2 with HelloService

use of org.apache.dubbo.config.spring.api.HelloService in project dubbo by alibaba.

the class ConfigTest method testProtocolRandomPort.

@Test
public void testProtocolRandomPort() throws Exception {
    ServiceConfig<DemoService> demoService = null;
    ServiceConfig<HelloService> helloService = null;
    ApplicationConfig application = new ApplicationConfig();
    application.setName("test-protocol-random-port");
    RegistryConfig registry = new RegistryConfig();
    registry.setAddress("N/A");
    ProtocolConfig protocol = new ProtocolConfig();
    protocol.setName("dubbo");
    protocol.setPort(-1);
    demoService = new ServiceConfig<DemoService>();
    demoService.setInterface(DemoService.class);
    demoService.setRef(new DemoServiceImpl());
    demoService.setApplication(application);
    demoService.setRegistry(registry);
    demoService.setProtocol(protocol);
    helloService = new ServiceConfig<HelloService>();
    helloService.setInterface(HelloService.class);
    helloService.setRef(new HelloServiceImpl());
    helloService.setApplication(application);
    helloService.setRegistry(registry);
    helloService.setProtocol(protocol);
    DubboBootstrap bootstrap = DubboBootstrap.getInstance().application(application).registry(registry).protocol(protocol).service(demoService).service(helloService);
    try {
        bootstrap.start();
        Assertions.assertEquals(demoService.getExportedUrls().get(0).getPort(), helloService.getExportedUrls().get(0).getPort());
    } finally {
        bootstrap.stop();
    }
}
Also used : RegistryConfig(org.apache.dubbo.config.RegistryConfig) ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) DemoService(org.apache.dubbo.config.spring.api.DemoService) HelloService(org.apache.dubbo.config.spring.api.HelloService) DubboBootstrap(org.apache.dubbo.config.bootstrap.DubboBootstrap) HelloServiceImpl(org.apache.dubbo.config.spring.impl.HelloServiceImpl) ProtocolConfig(org.apache.dubbo.config.ProtocolConfig) DemoServiceImpl(org.apache.dubbo.config.spring.impl.DemoServiceImpl) Test(org.junit.jupiter.api.Test)

Example 3 with HelloService

use of org.apache.dubbo.config.spring.api.HelloService in project dubbo by alibaba.

the class DubboReferenceGenericTest method test.

@Test
public void test() {
    assertEquals("Hello,World", stringService.getS());
    HelloService helloService = helloServiceManager.getService();
    assertEquals("Greeting, Mercy", helloService.sayHello("Mercy"));
}
Also used : HelloService(org.apache.dubbo.config.spring.api.HelloService) Test(org.junit.jupiter.api.Test)

Example 4 with HelloService

use of org.apache.dubbo.config.spring.api.HelloService in project dubbo by alibaba.

the class SpringExtensionFactoryTest method testGetExtensionByName.

@Test
public void testGetExtensionByName() {
    DemoService bean = springExtensionFactory.getExtension(DemoService.class, "bean1");
    Assertions.assertNotNull(bean);
    HelloService hello = springExtensionFactory.getExtension(HelloService.class, "hello");
    Assertions.assertNotNull(hello);
}
Also used : DemoService(org.apache.dubbo.config.spring.api.DemoService) HelloService(org.apache.dubbo.config.spring.api.HelloService) Test(org.junit.jupiter.api.Test)

Aggregations

HelloService (org.apache.dubbo.config.spring.api.HelloService)4 Test (org.junit.jupiter.api.Test)4 ApplicationConfig (org.apache.dubbo.config.ApplicationConfig)2 RegistryConfig (org.apache.dubbo.config.RegistryConfig)2 DubboBootstrap (org.apache.dubbo.config.bootstrap.DubboBootstrap)2 DemoService (org.apache.dubbo.config.spring.api.DemoService)2 ProtocolConfig (org.apache.dubbo.config.ProtocolConfig)1 ReferenceConfig (org.apache.dubbo.config.ReferenceConfig)1 DemoServiceImpl (org.apache.dubbo.config.spring.impl.DemoServiceImpl)1 HelloServiceImpl (org.apache.dubbo.config.spring.impl.HelloServiceImpl)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1