Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.apache.dubbo.rpc.Invoker;
import org.apache.dubbo.rpc.Protocol;
import org.apache.dubbo.rpc.service.GenericService;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
Expand All @@ -40,6 +39,7 @@
import org.mockito.Mockito;

import java.util.Collections;
import java.util.concurrent.TimeUnit;

import static org.apache.dubbo.common.Constants.GENERIC_SERIALIZATION_BEAN;
import static org.apache.dubbo.common.Constants.GENERIC_SERIALIZATION_DEFAULT;
Expand All @@ -52,6 +52,7 @@
import static org.hamcrest.Matchers.hasKey;
import static org.hamcrest.Matchers.hasSize;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.withSettings;

public class ServiceConfigTest {
Expand All @@ -60,7 +61,7 @@ public class ServiceConfigTest {
private Exporter exporter = Mockito.mock(Exporter.class);
private ServiceConfig<DemoServiceImpl> service = new ServiceConfig<DemoServiceImpl>();
private ServiceConfig<DemoServiceImpl> service2 = new ServiceConfig<DemoServiceImpl>();

private ServiceConfig<DemoServiceImpl> delayService = new ServiceConfig<DemoServiceImpl>();

@BeforeEach
public void setUp() throws Exception {
Expand Down Expand Up @@ -104,6 +105,14 @@ public void setUp() throws Exception {
service2.setMethods(Collections.singletonList(method));
service2.setProxy("testproxyfactory");

delayService.setProvider(provider);
delayService.setApplication(app);
delayService.setRegistry(registry);
delayService.setInterface(DemoService.class);
delayService.setRef(new DemoServiceImpl());
delayService.setMethods(Collections.singletonList(method));
delayService.setDelay(100);

ConfigManager.getInstance().clear();
}

Expand Down Expand Up @@ -143,6 +152,16 @@ public void testProxy() throws Exception {
assertEquals(2, TestProxyFactory.count); // local injvm and registry protocol, so expected is 2
}


@Test
public void testDelayExport() throws Exception {
delayService.export();
assertTrue(delayService.getExportedUrls().isEmpty());
//add 300ms to ensure that the delayService has been exported
Comment thread
LiZhenNet marked this conversation as resolved.
TimeUnit.MILLISECONDS.sleep(delayService.getDelay() + 300);
assertThat(delayService.getExportedUrls(), hasSize(1));
}

@Test
@Disabled("cannot pass in travis")
public void testUnexport() throws Exception {
Expand Down