Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wrr-cat
apollo
提交
c5d37036
apollo
项目概览
wrr-cat
/
apollo
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
apollo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
c5d37036
编写于
3月 17, 2016
作者:
Y
Yiming Liu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add Eureka Service Discovery
上级
ac0e32ed
变更
28
隐藏空白更改
内联
并排
Showing
28 changed file
with
197 addition
and
170 deletion
+197
-170
apollo-configserver/pom.xml
apollo-configserver/pom.xml
+1
-18
apollo-configserver/src/main/java/com/ctrip/apollo/configserver/service/DiscoveryService.java
...m/ctrip/apollo/configserver/service/DiscoveryService.java
+29
-0
apollo-configserver/src/main/resources/bootstrap.yml
apollo-configserver/src/main/resources/bootstrap.yml
+10
-4
apollo-configserver/src/test/java/com/ctrip/apollo/configserver/AbstractConfigServerTest.java
...m/ctrip/apollo/configserver/AbstractConfigServerTest.java
+1
-21
apollo-configserver/src/test/java/com/ctrip/apollo/configserver/ConfigServerApplicationTestConfiguration.java
...onfigserver/ConfigServerApplicationTestConfiguration.java
+0
-8
apollo-configserver/src/test/java/com/ctrip/apollo/configserver/service/DiscoveryServiceTest.java
...rip/apollo/configserver/service/DiscoveryServiceTest.java
+3
-3
apollo-configserver/src/test/resources/application.yml
apollo-configserver/src/test/resources/application.yml
+2
-2
apollo-configserver/src/test/resources/bootstrap.yml
apollo-configserver/src/test/resources/bootstrap.yml
+10
-7
apollo-metaserver/pom.xml
apollo-metaserver/pom.xml
+1
-18
apollo-metaserver/src/main/java/com/ctrip/apollo/metaserver/MetaServerApplication.java
...va/com/ctrip/apollo/metaserver/MetaServerApplication.java
+12
-9
apollo-metaserver/src/main/java/com/ctrip/apollo/metaserver/controller/ServiceController.java
...ctrip/apollo/metaserver/controller/ServiceController.java
+29
-0
apollo-metaserver/src/main/java/com/ctrip/apollo/metaserver/service/DiscoveryService.java
...com/ctrip/apollo/metaserver/service/DiscoveryService.java
+11
-11
apollo-metaserver/src/main/resources/application.yml
apollo-metaserver/src/main/resources/application.yml
+6
-3
apollo-metaserver/src/main/resources/bootstrap.yml
apollo-metaserver/src/main/resources/bootstrap.yml
+13
-4
apollo-metaserver/src/test/java/com/ctrip/apollo/metaserver/AbstractMetaServerTest.java
...a/com/ctrip/apollo/metaserver/AbstractMetaServerTest.java
+1
-21
apollo-metaserver/src/test/java/com/ctrip/apollo/metaserver/MetaServerApplicationTestConfiguration.java
...lo/metaserver/MetaServerApplicationTestConfiguration.java
+0
-10
apollo-metaserver/src/test/java/com/ctrip/apollo/metaserver/service/DiscoveryServiceTest.java
...ctrip/apollo/metaserver/service/DiscoveryServiceTest.java
+21
-0
apollo-metaserver/src/test/resources/application.yml
apollo-metaserver/src/test/resources/application.yml
+0
-3
apollo-metaserver/src/test/resources/bootstrap.yml
apollo-metaserver/src/test/resources/bootstrap.yml
+13
-4
apollo-portal/pom.xml
apollo-portal/pom.xml
+2
-2
apollo-portal/src/main/resources/application.properties
apollo-portal/src/main/resources/application.properties
+0
-3
apollo-portal/src/main/resources/application.yml
apollo-portal/src/main/resources/application.yml
+11
-0
apollo-portal/src/test/java/com/ctrip/apollo/portal/AbstractPortalTest.java
...test/java/com/ctrip/apollo/portal/AbstractPortalTest.java
+1
-1
apollo-portal/src/test/java/com/ctrip/apollo/portal/PortalApplicationTestConfiguration.java
...rip/apollo/portal/PortalApplicationTestConfiguration.java
+0
-8
apollo-portal/src/test/java/com/ctrip/apollo/portal/controller/AppControllerTest.java
...com/ctrip/apollo/portal/controller/AppControllerTest.java
+7
-3
apollo-portal/src/test/resources/application.properties
apollo-portal/src/test/resources/application.properties
+0
-5
apollo-portal/src/test/resources/application.yml
apollo-portal/src/test/resources/application.yml
+11
-0
pom.xml
pom.xml
+2
-2
未找到文件。
apollo-configserver/pom.xml
浏览文件 @
c5d37036
...
...
@@ -21,24 +21,12 @@
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-zookeeper-discovery
</artifactId>
</dependency>
<dependency>
<groupId>
org.apache.curator
</groupId>
<artifactId>
curator-x-discovery
</artifactId>
<artifactId>
spring-cloud-starter-eureka
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-jpa
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.data
</groupId>
<artifactId>
spring-data-redis
</artifactId>
</dependency>
<dependency>
<groupId>
redis.clients
</groupId>
<artifactId>
jedis
</artifactId>
</dependency>
<dependency>
<groupId>
com.h2database
</groupId>
<artifactId>
h2
</artifactId>
...
...
@@ -48,11 +36,6 @@
<artifactId>
mysql-connector-java
</artifactId>
<scope>
runtime
</scope>
</dependency>
<dependency>
<groupId>
org.apache.curator
</groupId>
<artifactId>
curator-test
</artifactId>
<scope>
test
</scope>
</dependency>
</dependencies>
<build>
<plugins>
...
...
apollo-configserver/src/main/java/com/ctrip/apollo/configserver/service/DiscoveryService.java
0 → 100644
浏览文件 @
c5d37036
package
com.ctrip.apollo.configserver.service
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cloud.client.ServiceInstance
;
import
org.springframework.cloud.client.discovery.DiscoveryClient
;
import
org.springframework.stereotype.Service
;
import
com.ctrip.apollo.core.ServiceIdConsts
;
@Service
public
class
DiscoveryService
{
@Autowired
private
DiscoveryClient
discoveryClient
;
public
List
<
ServiceInstance
>
getConfigServerServiceInstances
()
{
List
<
ServiceInstance
>
instances
=
discoveryClient
.
getInstances
(
ServiceIdConsts
.
APOLLO_CONFIGSERVER
);
return
instances
;
}
public
List
<
ServiceInstance
>
getMetaServerServiceInstances
()
{
List
<
ServiceInstance
>
instances
=
discoveryClient
.
getInstances
(
ServiceIdConsts
.
APOLLO_METASERVER
);
return
instances
;
}
}
apollo-configserver/src/main/resources/bootstrap.yml
浏览文件 @
c5d37036
spring
:
cloud
:
zookeeper
:
connectString
:
10.3.2.57:2181,10.3.2.58:2181,10.3.2.59:2181
\ No newline at end of file
eureka
:
instance
:
hostname
:
localhost
preferIpAddress
:
true
client
:
fetchRegistry
:
false
serviceUrl
:
defaultZone
:
http://${eureka.instance.hostname}:${server.port}/eureka/
healthcheck
:
enabled
:
true
\ No newline at end of file
apollo-configserver/src/test/java/com/ctrip/apollo/configserver/AbstractConfigServerTest.java
浏览文件 @
c5d37036
package
com.ctrip.apollo.configserver
;
import
java.io.IOException
;
import
org.apache.curator.test.TestingServer
;
import
org.junit.AfterClass
;
import
org.junit.BeforeClass
;
import
org.junit.runner.RunWith
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
ConfigServerApplication
TestConfiguration
.
class
)
@SpringApplicationConfiguration
(
classes
=
ConfigServerApplication
.
class
)
public
abstract
class
AbstractConfigServerTest
{
private
static
TestingServer
zkTestServer
;
@BeforeClass
public
static
void
beforeClass
()
throws
Exception
{
zkTestServer
=
new
TestingServer
(
2181
,
false
);
zkTestServer
.
start
();
System
.
out
.
format
(
"embedded zookeeper is up %s%n"
,
zkTestServer
.
getConnectString
());
}
@AfterClass
public
static
void
afterClass
()
throws
IOException
{
if
(
zkTestServer
!=
null
)
{
zkTestServer
.
close
();
}
}
}
apollo-configserver/src/test/java/com/ctrip/apollo/configserver/ConfigServerApplicationTestConfiguration.java
已删除
100644 → 0
浏览文件 @
ac0e32ed
package
com.ctrip.apollo.configserver
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
@SpringBootApplication
public
class
ConfigServerApplicationTestConfiguration
{
}
apollo-
metaserver/src/test/java/com/ctrip/apollo/metaserver/service/ServiceDiscovery
Test.java
→
apollo-
configserver/src/test/java/com/ctrip/apollo/configserver/service/DiscoveryService
Test.java
浏览文件 @
c5d37036
package
com.ctrip.apollo.
meta
server.service
;
package
com.ctrip.apollo.
config
server.service
;
import
java.util.List
;
...
...
@@ -6,9 +6,9 @@ import org.junit.Test;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cloud.client.ServiceInstance
;
import
com.ctrip.apollo.
metaserver.AbstractMeta
ServerTest
;
import
com.ctrip.apollo.
configserver.AbstractConfig
ServerTest
;
public
class
ServiceDiscoveryTest
extends
AbstractMeta
ServerTest
{
public
class
DiscoveryServiceTest
extends
AbstractConfig
ServerTest
{
@Autowired
private
DiscoveryService
discoveryService
;
...
...
apollo-configserver/src/test/resources/application.yml
浏览文件 @
c5d37036
...
...
@@ -6,8 +6,8 @@ logging:
org.springframework.cloud
:
'
DEBUG'
spring
:
profiles
:
active
:
native
application
:
name
:
apollo-configserver
datasource
:
url
:
jdbc:h2:file:~/fxapolloconfigdb;DB_CLOSE_ON_EXIT=FALSE
username
:
sa
...
...
apollo-configserver/src/test/resources/bootstrap.yml
浏览文件 @
c5d37036
spring
:
application
:
name
:
apollo-configserver
cloud
:
zookeeper
:
connectString:localhost:2181
\ No newline at end of file
eureka
:
instance
:
hostname
:
localhost
preferIpAddress
:
true
client
:
fetchRegistry
:
false
serviceUrl
:
defaultZone
:
http://${eureka.instance.hostname}:${server.port}/eureka/
healthcheck
:
enabled
:
true
\ No newline at end of file
apollo-metaserver/pom.xml
浏览文件 @
c5d37036
...
...
@@ -17,24 +17,7 @@
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-config
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-zookeeper-discovery
</artifactId>
</dependency>
<dependency>
<groupId>
org.apache.curator
</groupId>
<artifactId>
curator-x-discovery
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
</dependency>
<dependency>
<groupId>
org.apache.curator
</groupId>
<artifactId>
curator-test
</artifactId>
<scope>
test
</scope>
<artifactId>
spring-cloud-starter-eureka-server
</artifactId>
</dependency>
</dependencies>
<build>
...
...
apollo-metaserver/src/main/java/com/ctrip/apollo/metaserver/MetaServerApplication.java
浏览文件 @
c5d37036
...
...
@@ -2,22 +2,25 @@ package com.ctrip.apollo.metaserver;
import
java.util.List
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.cloud.client.ServiceInstance
;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
import
org.springframework.cloud.netflix.eureka.EnableEurekaClient
;
import
org.springframework.cloud.netflix.eureka.server.EnableEurekaServer
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
com.ctrip.apollo.metaserver.service.DiscoveryService
;
import
com.netflix.appinfo.InstanceInfo
;
@SpringBootApplication
@EnableDiscoveryClient
@EnableEurekaServer
@EnableEurekaClient
public
class
MetaServerApplication
{
public
static
void
main
(
String
[]
args
)
{
ApplicationContext
context
=
SpringApplication
.
run
(
MetaServerApplication
.
class
,
args
);
List
<
ServiceInstance
>
metaServerServiceInstances
=
context
.
getBean
(
DiscoveryService
.
class
).
getMetaServerServiceInstances
();
System
.
out
.
println
(
metaServerServiceInstances
);
ConfigurableApplicationContext
context
=
new
SpringApplicationBuilder
(
MetaServerApplication
.
class
).
web
(
true
).
run
(
args
);
DiscoveryService
discoveryService
=
context
.
getBean
(
DiscoveryService
.
class
);
List
<
InstanceInfo
>
instances
=
discoveryService
.
getMetaServerServiceInstance
();
System
.
out
.
println
(
instances
);
}
}
apollo-metaserver/src/main/java/com/ctrip/apollo/metaserver/controller/ServiceController.java
0 → 100644
浏览文件 @
c5d37036
package
com.ctrip.apollo.metaserver.controller
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.ctrip.apollo.metaserver.service.DiscoveryService
;
import
com.netflix.appinfo.InstanceInfo
;
@RestController
@RequestMapping
(
"/services"
)
public
class
ServiceController
{
@Autowired
private
DiscoveryService
discoveryService
;
@RequestMapping
(
"/meta"
)
public
List
<
InstanceInfo
>
metaServer
()
{
return
discoveryService
.
getMetaServerServiceInstance
();
}
@RequestMapping
(
"/config"
)
public
List
<
InstanceInfo
>
configServer
()
{
return
discoveryService
.
getConfigServerServiceInstance
();
}
}
apollo-metaserver/src/main/java/com/ctrip/apollo/metaserver/service/DiscoveryService.java
浏览文件 @
c5d37036
...
...
@@ -3,27 +3,27 @@ package com.ctrip.apollo.metaserver.service;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cloud.client.ServiceInstance
;
import
org.springframework.cloud.client.discovery.DiscoveryClient
;
import
org.springframework.stereotype.Service
;
import
com.ctrip.apollo.core.ServiceIdConsts
;
import
com.netflix.appinfo.InstanceInfo
;
import
com.netflix.discovery.EurekaClient
;
import
com.netflix.discovery.shared.Application
;
@Service
public
class
DiscoveryService
{
@Autowired
private
DiscoveryClient
discovery
Client
;
private
EurekaClient
eureka
Client
;
public
List
<
ServiceInstance
>
getConfigServerServiceInstances
()
{
List
<
ServiceInstance
>
instances
=
discoveryClient
.
getInstances
(
ServiceIdConsts
.
APOLLO_CONFIGSERVER
);
return
instances
;
public
List
<
InstanceInfo
>
getConfigServerServiceInstance
()
{
Application
application
=
eurekaClient
.
getApplication
(
ServiceIdConsts
.
APOLLO_CONFIGSERVER
);
return
application
.
getInstances
();
}
public
List
<
ServiceInstance
>
getMetaServerServiceInstances
()
{
List
<
ServiceInstance
>
instances
=
discoveryClient
.
getInstances
(
ServiceIdConsts
.
APOLLO_METASERVER
);
return
instances
;
public
List
<
InstanceInfo
>
getMetaServerServiceInstance
()
{
Application
application
=
eurekaClient
.
getApplication
(
ServiceIdConsts
.
APOLLO_METASERVER
);
return
application
.
getInstances
();
}
}
apollo-metaserver/src/main/resources/application.yml
浏览文件 @
c5d37036
server
:
port
:
80
spring
:
application
:
name
:
apollo-metaserver
profiles
:
active
:
native
logging
:
level
:
\ No newline at end of file
apollo-metaserver/src/main/resources/bootstrap.yml
浏览文件 @
c5d37036
spring
:
cloud
:
zookeeper
:
connectString
:
10.3.2.57:2181,10.3.2.58:2181,10.3.2.59:2181
\ No newline at end of file
server
:
port
:
8761
eureka
:
instance
:
hostname
:
localhost
preferIpAddress
:
true
client
:
fetchRegistry
:
false
serviceUrl
:
defaultZone
:
http://${eureka.instance.hostname}:${server.port}/eureka/
healthcheck
:
enabled
:
true
\ No newline at end of file
apollo-metaserver/src/test/java/com/ctrip/apollo/metaserver/AbstractMetaServerTest.java
浏览文件 @
c5d37036
package
com.ctrip.apollo.metaserver
;
import
java.io.IOException
;
import
org.apache.curator.test.TestingServer
;
import
org.junit.AfterClass
;
import
org.junit.BeforeClass
;
import
org.junit.runner.RunWith
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
MetaServerApplication
TestConfiguration
.
class
)
@SpringApplicationConfiguration
(
classes
=
MetaServerApplication
.
class
)
public
abstract
class
AbstractMetaServerTest
{
private
static
TestingServer
zkTestServer
;
@BeforeClass
public
static
void
beforeClass
()
throws
Exception
{
zkTestServer
=
new
TestingServer
(
2181
,
false
);
zkTestServer
.
start
();
System
.
out
.
format
(
"embedded zookeeper is up %s%n"
,
zkTestServer
.
getConnectString
());
}
@AfterClass
public
static
void
afterClass
()
throws
IOException
{
if
(
zkTestServer
!=
null
)
{
zkTestServer
.
close
();
}
}
}
apollo-metaserver/src/test/java/com/ctrip/apollo/metaserver/MetaServerApplicationTestConfiguration.java
已删除
100644 → 0
浏览文件 @
ac0e32ed
package
com.ctrip.apollo.metaserver
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
@SpringBootApplication
//@EnableDiscoveryClient
public
class
MetaServerApplicationTestConfiguration
{
}
apollo-metaserver/src/test/java/com/ctrip/apollo/metaserver/service/DiscoveryServiceTest.java
0 → 100644
浏览文件 @
c5d37036
package
com.ctrip.apollo.metaserver.service
;
import
java.util.List
;
import
org.junit.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
com.ctrip.apollo.metaserver.AbstractMetaServerTest
;
import
com.netflix.appinfo.InstanceInfo
;
public
class
DiscoveryServiceTest
extends
AbstractMetaServerTest
{
@Autowired
private
DiscoveryService
discoveryService
;
@Test
public
void
testGetLocalMetaServerServices
()
{
List
<
InstanceInfo
>
instances
=
discoveryService
.
getMetaServerServiceInstance
();
System
.
out
.
println
(
instances
);
}
}
apollo-metaserver/src/test/resources/application.yml
浏览文件 @
c5d37036
server
:
port
:
80
spring
:
application
:
name
:
apollo-metaserver
...
...
apollo-metaserver/src/test/resources/bootstrap.yml
浏览文件 @
c5d37036
spring
:
cloud
:
zookeeper
:
connectString
:
localhost:2181
\ No newline at end of file
server
:
port
:
8761
eureka
:
instance
:
hostname
:
localhost
preferIpAddress
:
true
client
:
fetchRegistry
:
false
serviceUrl
:
defaultZone
:
http://${eureka.instance.hostname}:${server.port}/eureka/
healthcheck
:
enabled
:
true
\ No newline at end of file
apollo-portal/pom.xml
浏览文件 @
c5d37036
...
...
@@ -16,8 +16,8 @@
<artifactId>
apollo-core
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.
boot
</groupId>
<artifactId>
spring-
boot-starter-web
</artifactId>
<groupId>
org.springframework.
cloud
</groupId>
<artifactId>
spring-
cloud-starter-eureka
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
...
...
apollo-portal/src/main/resources/application.properties
已删除
100644 → 0
浏览文件 @
ac0e32ed
spring.datasource.url
=
jdbc:h2:file:~/fxapolloportaldb
spring.datasource.username
=
sa
spring.datasource.password
=
sa
apollo-portal/src/main/resources/application.yml
0 → 100644
浏览文件 @
c5d37036
server
:
port
:
80
spring
:
application
:
name
:
apollo-portal
datasource
:
url
:
jdbc:h2:file:~/fxapolloportaldb
username
:
sa
password
:
sa
apollo-portal/src/test/java/com/ctrip/apollo/portal/AbstractPortalTest.java
浏览文件 @
c5d37036
...
...
@@ -5,7 +5,7 @@ import org.springframework.boot.test.SpringApplicationConfiguration;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
PortalApplication
TestConfiguration
.
class
)
@SpringApplicationConfiguration
(
classes
=
PortalApplication
.
class
)
public
abstract
class
AbstractPortalTest
{
}
apollo-portal/src/test/java/com/ctrip/apollo/portal/PortalApplicationTestConfiguration.java
已删除
100644 → 0
浏览文件 @
ac0e32ed
package
com.ctrip.apollo.portal
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
@SpringBootApplication
public
class
PortalApplicationTestConfiguration
{
}
apollo-portal/src/test/java/com/ctrip/apollo/portal/controller/AppControllerTest.java
浏览文件 @
c5d37036
...
...
@@ -6,6 +6,7 @@ import java.net.URISyntaxException;
import
org.junit.Assert
;
import
org.junit.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.test.TestRestTemplate
;
import
org.springframework.boot.test.WebIntegrationTest
;
import
org.springframework.http.HttpStatus
;
...
...
@@ -25,6 +26,9 @@ public class AppControllerTest extends AbstractPortalTest {
@Autowired
AppRepository
appRepository
;
@Value
(
"${server.port}"
)
String
serverPort
;
@Test
public
void
testCreate
()
throws
URISyntaxException
{
App
newApp
=
new
App
();
...
...
@@ -32,7 +36,7 @@ public class AppControllerTest extends AbstractPortalTest {
newApp
.
setName
(
"new app "
+
System
.
currentTimeMillis
());
newApp
.
setOwner
(
"owner "
+
System
.
currentTimeMillis
());
URI
uri
=
new
URI
(
"http://localhost:
8080
/apps"
);
URI
uri
=
new
URI
(
"http://localhost:
"
+
serverPort
+
"
/apps"
);
App
createdApp
=
restTemplate
.
postForObject
(
uri
,
newApp
,
App
.
class
);
Assert
.
assertEquals
(
newApp
.
getAppId
(),
createdApp
.
getAppId
());
...
...
@@ -52,7 +56,7 @@ public class AppControllerTest extends AbstractPortalTest {
newApp
.
setOwner
(
"owner "
+
System
.
currentTimeMillis
());
appRepository
.
save
(
newApp
);
URI
uri
=
new
URI
(
"http://localhost:
8080
/apps"
);
URI
uri
=
new
URI
(
"http://localhost:
"
+
serverPort
+
"
/apps"
);
App
[]
apps
=
restTemplate
.
getForObject
(
uri
,
App
[].
class
);
Assert
.
assertEquals
(
1
,
apps
.
length
);
...
...
@@ -67,7 +71,7 @@ public class AppControllerTest extends AbstractPortalTest {
newApp
.
setOwner
(
"owner "
+
System
.
currentTimeMillis
());
appRepository
.
save
(
newApp
);
URI
uri
=
new
URI
(
"http://localhost:
8080
/apps?page=2"
);
URI
uri
=
new
URI
(
"http://localhost:
"
+
serverPort
+
"
/apps?page=2"
);
ResponseEntity
<
App
[]>
entity
=
restTemplate
.
getForEntity
(
uri
,
App
[].
class
);
Assert
.
assertEquals
(
HttpStatus
.
NOT_FOUND
,
entity
.
getStatusCode
());
...
...
apollo-portal/src/test/resources/application.properties
已删除
100644 → 0
浏览文件 @
ac0e32ed
spring.datasource.url
=
jdbc:h2:mem:fxapolloportaldb
spring.datasource.username
=
sa
spring.datasource.password
=
spring.jpa.show-sql: true
\ No newline at end of file
apollo-portal/src/test/resources/application.yml
0 → 100644
浏览文件 @
c5d37036
server
:
port
:
80
spring
:
datasource
:
url
:
jdbc:h2:file:~/fxapolloportaldb
username
:
sa
password
:
sa
jpa
:
show-sql
:
true
pom.xml
浏览文件 @
c5d37036
...
...
@@ -118,8 +118,8 @@
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-
zookeeper
</artifactId>
<version>
1.
0
.0.M5
</version>
<artifactId>
spring-cloud-
netflix
</artifactId>
<version>
1.
1
.0.M5
</version>
<type>
pom
</type>
<scope>
import
</scope>
</dependency>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录