Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wrr-cat
apollo
提交
329e882e
apollo
项目概览
wrr-cat
/
apollo
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
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,发现更多精彩内容 >>
提交
329e882e
编写于
4月 08, 2016
作者:
J
Jason Song
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #69 from yiming187/test_update
Add JPA lifecycle annotation & Integrate env in portal
上级
c56c0db7
daaffa93
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
98 addition
and
55 deletion
+98
-55
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/App.java
...lo-biz/src/main/java/com/ctrip/apollo/biz/entity/App.java
+1
-1
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/BaseEntity.java
...src/main/java/com/ctrip/apollo/biz/entity/BaseEntity.java
+20
-1
apollo-biz/src/test/java/com/ctrip/apollo/biz/AllTests.java
apollo-biz/src/test/java/com/ctrip/apollo/biz/AllTests.java
+7
-1
apollo-biz/src/test/java/com/ctrip/apollo/biz/repository/AppRepositoryTest.java
...va/com/ctrip/apollo/biz/repository/AppRepositoryTest.java
+47
-2
apollo-biz/src/test/resources/application.properties
apollo-biz/src/test/resources/application.properties
+2
-1
apollo-biz/src/test/resources/import.sql
apollo-biz/src/test/resources/import.sql
+0
-31
apollo-portal/src/main/java/com/ctrip/apollo/portal/service/AppService.java
...main/java/com/ctrip/apollo/portal/service/AppService.java
+20
-12
apollo-portal/src/main/resources/application.yml
apollo-portal/src/main/resources/application.yml
+1
-6
未找到文件。
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/App.java
浏览文件 @
329e882e
...
...
@@ -14,7 +14,7 @@ public class App extends BaseEntity {
@Column
(
nullable
=
false
)
private
String
name
;
@Column
(
nullable
=
false
,
unique
=
true
)
@Column
(
nullable
=
false
)
private
String
appId
;
@Column
(
nullable
=
false
)
...
...
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/BaseEntity.java
浏览文件 @
329e882e
...
...
@@ -8,6 +8,9 @@ import javax.persistence.Id;
import
javax.persistence.Inheritance
;
import
javax.persistence.InheritanceType
;
import
javax.persistence.MappedSuperclass
;
import
javax.persistence.PrePersist
;
import
javax.persistence.PreRemove
;
import
javax.persistence.PreUpdate
;
@MappedSuperclass
@Inheritance
(
strategy
=
InheritanceType
.
TABLE_PER_CLASS
)
...
...
@@ -17,7 +20,8 @@ public abstract class BaseEntity {
@GeneratedValue
private
long
id
;
private
boolean
isDeleted
;
@Column
(
name
=
"IsDeleted"
)
protected
boolean
isDeleted
;
@Column
(
name
=
"DataChange_CreatedBy"
)
private
String
dataChangeCreatedBy
;
...
...
@@ -78,4 +82,19 @@ public abstract class BaseEntity {
public
void
setId
(
long
id
)
{
this
.
id
=
id
;
}
@PrePersist
private
void
prePersist
()
{
if
(
this
.
dataChangeCreatedTime
==
null
)
dataChangeCreatedTime
=
new
Date
();
}
@PreUpdate
private
void
preUpdate
()
{
this
.
dataChangeLastModifiedTime
=
new
Date
();
}
@PreRemove
private
void
preRemove
()
{
this
.
dataChangeLastModifiedTime
=
new
Date
();
}
}
apollo-biz/src/test/java/com/ctrip/apollo/biz/AllTests.java
浏览文件 @
329e882e
package
com.ctrip.apollo.biz
;
import
com.ctrip.apollo.biz.repository.AppRepositoryTest
;
import
com.ctrip.apollo.biz.service.AdminServiceTest
;
import
com.ctrip.apollo.biz.service.ConfigServiceTest
;
import
com.ctrip.apollo.biz.service.PrivilegeServiceTest
;
import
org.junit.runner.RunWith
;
import
org.junit.runners.Suite
;
...
...
@@ -8,7 +11,10 @@ import org.junit.runners.Suite.SuiteClasses;
@RunWith
(
Suite
.
class
)
@SuiteClasses
({
ConfigServiceTest
.
class
})
AppRepositoryTest
.
class
,
AdminServiceTest
.
class
,
ConfigServiceTest
.
class
,
PrivilegeServiceTest
.
class
})
public
class
AllTests
{
}
apollo-biz/src/test/java/com/ctrip/apollo/biz/repository/AppRepositoryTest.java
浏览文件 @
329e882e
package
com.ctrip.apollo.biz.repository
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -8,6 +9,7 @@ import org.springframework.boot.test.SpringApplicationConfiguration;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
com.ctrip.apollo.biz.SpringTestConfiguration
;
import
com.ctrip.apollo.biz.entity.App
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
SpringTestConfiguration
.
class
)
...
...
@@ -16,9 +18,52 @@ public class AppRepositoryTest {
@Autowired
private
AppRepository
appRepository
;
@Before
public
void
before
()
{
appRepository
.
deleteAll
();
}
@Test
public
void
testListExists
()
{
Assert
.
assertTrue
(
appRepository
.
count
()
>
0
);
public
void
testCreate
()
{
String
appId
=
"someAppId"
;
String
appName
=
"someAppName"
;
String
ownerName
=
"someOwnerName"
;
String
ownerEmail
=
"someOwnerName@ctrip.com"
;
App
app
=
new
App
();
app
.
setAppId
(
appId
);
app
.
setName
(
appName
);
app
.
setOwnerName
(
ownerName
);
app
.
setOwnerEmail
(
ownerEmail
);
Assert
.
assertEquals
(
0
,
appRepository
.
count
());
appRepository
.
save
(
app
);
Assert
.
assertEquals
(
1
,
appRepository
.
count
());
}
@Test
public
void
testRemove
()
{
String
appId
=
"someAppId"
;
String
appName
=
"someAppName"
;
String
ownerName
=
"someOwnerName"
;
String
ownerEmail
=
"someOwnerName@ctrip.com"
;
App
app
=
new
App
();
app
.
setAppId
(
appId
);
app
.
setName
(
appName
);
app
.
setOwnerName
(
ownerName
);
app
.
setOwnerEmail
(
ownerEmail
);
Assert
.
assertEquals
(
0
,
appRepository
.
count
());
appRepository
.
save
(
app
);
Assert
.
assertEquals
(
1
,
appRepository
.
count
());
appRepository
.
delete
(
app
.
getId
());
Assert
.
assertEquals
(
0
,
appRepository
.
count
());
}
}
apollo-biz/src/test/resources/application.properties
浏览文件 @
329e882e
spring.datasource.url
=
jdbc:h2:mem:~/
fxapolloconfigdb;mode=mysql
spring.datasource.url
=
jdbc:h2:mem:~/
apolloconfigdb;mode=mysql;DB_CLOSE_ON_EXIT=FALSE
spring.jpa.hibernate.naming_strategy
=
org.hibernate.cfg.EJB3NamingStrategy
spring.jpa.properties.hibernate.show_sql
=
true
spring.h2.console.enabled
=
true
spring.h2.console.settings.web-allow-others
=
true
apollo-biz/src/test/resources/import.sql
已删除
100644 → 0
浏览文件 @
c56c0db7
INSERT
INTO
App
(
AppId
,
Name
,
OwnerName
,
OwnerEmail
)
VALUES
(
'100003171'
,
'apollo-config-service'
,
'刘一鸣'
,
'liuym@ctrip.com'
);
INSERT
INTO
App
(
AppId
,
Name
,
OwnerName
,
OwnerEmail
)
VALUES
(
'100003172'
,
'apollo-admin-service'
,
'宋顺'
,
'song_s@ctrip.com'
);
INSERT
INTO
App
(
AppId
,
Name
,
OwnerName
,
OwnerEmail
)
VALUES
(
'100003173'
,
'apollo-portal'
,
'张乐'
,
'zhanglea@ctrip.com'
);
INSERT
INTO
App
(
AppId
,
Name
,
OwnerName
,
OwnerEmail
)
VALUES
(
'fxhermesproducer'
,
'fx-hermes-producer'
,
'梁锦华'
,
'jhliang@ctrip.com'
);
INSERT
INTO
Cluster
(
AppId
,
Name
)
VALUES
(
'100003171'
,
'default'
);
INSERT
INTO
Cluster
(
AppId
,
Name
)
VALUES
(
'100003171'
,
'cluster1'
);
INSERT
INTO
Cluster
(
AppId
,
Name
)
VALUES
(
'100003172'
,
'default'
);
INSERT
INTO
Cluster
(
AppId
,
Name
)
VALUES
(
'100003172'
,
'cluster2'
);
INSERT
INTO
Cluster
(
AppId
,
Name
)
VALUES
(
'100003173'
,
'default'
);
INSERT
INTO
Cluster
(
AppId
,
Name
)
VALUES
(
'100003173'
,
'cluster3'
);
INSERT
INTO
Cluster
(
AppId
,
Name
)
VALUES
(
'fxhermesproducer'
,
'default'
);
INSERT
INTO
AppNamespace
(
AppId
,
Name
)
VALUES
(
'100003171'
,
'application'
);
INSERT
INTO
AppNamespace
(
AppId
,
Name
)
VALUES
(
'100003172'
,
'application'
);
INSERT
INTO
AppNamespace
(
AppId
,
Name
)
VALUES
(
'100003173'
,
'application'
);
INSERT
INTO
AppNamespace
(
AppID
,
Name
)
VALUES
(
'fxhermesproducer'
,
'application'
);
INSERT
INTO
Namespace
(
Id
,
AppId
,
ClusterName
,
NamespaceName
)
VALUES
(
1
,
'100003171'
,
'default'
,
'application'
);
INSERT
INTO
Namespace
(
Id
,
AppId
,
ClusterName
,
NamespaceName
)
VALUES
(
2
,
'fxhermesproducer'
,
'default'
,
'application'
);
INSERT
INTO
Namespace
(
Id
,
AppId
,
ClusterName
,
NamespaceName
)
VALUES
(
3
,
'100003172'
,
'default'
,
'application'
);
INSERT
INTO
Namespace
(
Id
,
AppId
,
ClusterName
,
NamespaceName
)
VALUES
(
4
,
'100003173'
,
'default'
,
'application'
);
INSERT
INTO
Namespace
(
Id
,
AppId
,
ClusterName
,
NamespaceName
)
VALUES
(
5
,
'100003171'
,
'default'
,
'application'
);
INSERT
INTO
Item
(
NamespaceId
,
`Key`
,
Value
,
Comment
)
VALUES
(
1
,
'k1'
,
'v1'
,
'comment1'
);
INSERT
INTO
Item
(
NamespaceId
,
`Key`
,
Value
,
Comment
)
VALUES
(
1
,
'k2'
,
'v2'
,
'comment2'
);
INSERT
INTO
Item
(
NamespaceId
,
`Key`
,
Value
,
Comment
)
VALUES
(
2
,
'k3'
,
'v3'
,
'comment3'
);
INSERT
INTO
Item
(
NamespaceId
,
`Key`
,
Value
,
Comment
)
VALUES
(
5
,
'k3'
,
'v4'
,
'comment4'
);
INSERT
INTO
RELEASE
(
Name
,
Comment
,
AppId
,
ClusterName
,
NamespaceName
,
Configurations
)
VALUES
(
'REV1'
,
'First Release'
,
'100003171'
,
'default'
,
'application'
,
'{"k1":"v1"}'
);
apollo-portal/src/main/java/com/ctrip/apollo/portal/service/AppService.java
浏览文件 @
329e882e
package
com.ctrip.apollo.portal.service
;
import
com.ctrip.apollo.Apollo
;
import
com.ctrip.apollo.portal.entity.ClusterNavTree
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.ctrip.apollo.Apollo.Env
;
import
com.ctrip.apollo.portal.PortalSettings
;
import
com.ctrip.apollo.portal.entity.ClusterNavTree
;
@Service
public
class
AppService
{
...
...
@@ -13,18 +16,23 @@ public class AppService {
@Autowired
private
ClusterService
clusterService
;
public
ClusterNavTree
buildClusterNavTree
(
String
appId
){
ClusterNavTree
tree
=
new
ClusterNavTree
()
;
@Autowired
private
PortalSettings
portalSettings
;
ClusterNavTree
.
Node
localNode
=
new
ClusterNavTree
.
Node
(
Apollo
.
Env
.
LOCAL
);
localNode
.
setClusters
(
clusterService
.
findClusters
(
Apollo
.
Env
.
LOCAL
,
appId
));
tree
.
addNode
(
localNode
);
public
ClusterNavTree
buildClusterNavTree
(
String
appId
)
{
ClusterNavTree
tree
=
new
ClusterNavTree
();
// ClusterNavTree.Node uatNode = new ClusterNavTree.Node(Apollo.Env.UAT);
// List<ClusterDTO> uatClusters = new LinkedList<>();
// uatClusters.add(defaultCluster);
// uatNode.setClusters(uatClusters);
// tree.addNode(uatNode);
List
<
Env
>
envs
=
portalSettings
.
getEnvs
();
for
(
Env
env
:
envs
)
{
ClusterNavTree
.
Node
clusterNode
=
new
ClusterNavTree
.
Node
(
env
);
clusterNode
.
setClusters
(
clusterService
.
findClusters
(
env
,
appId
));
tree
.
addNode
(
clusterNode
);
}
// ClusterNavTree.Node uatNode = new ClusterNavTree.Node(Apollo.Env.UAT);
// List<ClusterDTO> uatClusters = new LinkedList<>();
// uatClusters.add(defaultCluster);
// uatNode.setClusters(uatClusters);
// tree.addNode(uatNode);
return
tree
;
}
...
...
apollo-portal/src/main/resources/application.yml
浏览文件 @
329e882e
...
...
@@ -4,11 +4,6 @@ server:
spring
:
application
:
name
:
apollo-portal
datasource
:
url
:
jdbc:h2:mem:~/fxapolloportaldb
jpa
:
hibernate
:
naming_strategy
:
org.hibernate.cfg.EJB3NamingStrategy
logging
:
level
:
...
...
@@ -20,4 +15,4 @@ ctrip:
apollo
:
portal
:
env
:
local,dev
,fws,uat
env
:
local,dev
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录