diff --git a/dubbo-spring-boot-compatible/autoconfigure/pom.xml b/dubbo-spring-boot-compatible/autoconfigure/pom.xml index a5a56a337..b45de5aba 100644 --- a/dubbo-spring-boot-compatible/autoconfigure/pom.xml +++ b/dubbo-spring-boot-compatible/autoconfigure/pom.xml @@ -65,6 +65,29 @@ dubbo + + org.apache.dubbo + dubbo-dependencies-zookeeper + ${dubbo.version} + pom + import + + + log4j + log4j + + + slf4j-log4j12 + org.slf4j + + + + + + javax.annotation + javax.annotation-api + + org.springframework.boot @@ -72,7 +95,11 @@ test - + + org.apache.curator + curator-test + test + \ No newline at end of file diff --git a/dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/DubboAutoConfigurationOnSingleConfigTest.java b/dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/DubboAutoConfigurationOnSingleConfigTest.java index 26fb6bd50..004d52711 100644 --- a/dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/DubboAutoConfigurationOnSingleConfigTest.java +++ b/dubbo-spring-boot-compatible/autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/DubboAutoConfigurationOnSingleConfigTest.java @@ -16,6 +16,7 @@ */ package org.apache.dubbo.spring.boot.autoconfigure; +import org.apache.curator.test.TestingServer; import org.apache.dubbo.config.ApplicationConfig; import org.apache.dubbo.config.ConsumerConfig; import org.apache.dubbo.config.ModuleConfig; @@ -24,10 +25,11 @@ import org.apache.dubbo.config.ProviderConfig; import org.apache.dubbo.config.RegistryConfig; import org.apache.dubbo.rpc.model.ApplicationModel; - import org.junit.After; +import org.junit.AfterClass; import org.junit.Assert; import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -38,6 +40,8 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; +import java.io.IOException; + /** * {@link DubboAutoConfiguration} Test On single Dubbo Configuration * @@ -48,10 +52,10 @@ properties = { "dubbo.application.name = dubbo-demo-application", "dubbo.module.name = dubbo-demo-module", - "dubbo.registry.address = zookeeper://192.168.99.100:32770", + "dubbo.registry.address = zookeeper://127.0.0.1:"+ DubboAutoConfigurationOnSingleConfigTest.zkServerPort, "dubbo.protocol.name=dubbo", "dubbo.protocol.port=20880", - "dubbo.monitor.address=zookeeper://127.0.0.1:32770", + "dubbo.monitor.address=zookeeper://127.0.0.1:"+ DubboAutoConfigurationOnSingleConfigTest.zkServerPort, "dubbo.provider.host=127.0.0.1", "dubbo.consumer.client=netty" } @@ -62,6 +66,8 @@ @EnableAutoConfiguration public class DubboAutoConfigurationOnSingleConfigTest { + static final int zkServerPort = 32770; + @Autowired private ApplicationConfig applicationConfig; @@ -89,6 +95,18 @@ public class DubboAutoConfigurationOnSingleConfigTest { @Autowired private ApplicationContext applicationContext; + private static TestingServer zkServer; + + @BeforeClass + public static void setup() throws Exception { + zkServer = new TestingServer(zkServerPort, true); + } + + @AfterClass + public static void shutdown() throws IOException { + zkServer.close(); + } + @Before public void init() { ApplicationModel.reset(); @@ -116,14 +134,14 @@ public void testModuleConfig() { @Test public void testRegistryConfig() { - Assert.assertEquals("zookeeper://192.168.99.100:32770", registryConfig.getAddress()); + Assert.assertEquals("zookeeper://127.0.0.1:"+ DubboAutoConfigurationOnSingleConfigTest.zkServerPort, registryConfig.getAddress()); } @Test public void testMonitorConfig() { - Assert.assertEquals("zookeeper://127.0.0.1:32770", monitorConfig.getAddress()); + Assert.assertEquals("zookeeper://127.0.0.1:"+ DubboAutoConfigurationOnSingleConfigTest.zkServerPort, monitorConfig.getAddress()); } diff --git a/dubbo-spring-boot-parent/pom.xml b/dubbo-spring-boot-parent/pom.xml index 81ae9ecab..8ba741930 100644 --- a/dubbo-spring-boot-parent/pom.xml +++ b/dubbo-spring-boot-parent/pom.xml @@ -96,6 +96,12 @@ + + javax.annotation + javax.annotation-api + 1.3.2 + +