Skip to content

Commit 55a0e1b

Browse files
committed
upgrade spring boot to 2.0.5 and spring cloud to Finchley.SR1
1 parent 425de29 commit 55a0e1b

File tree

88 files changed

+277
-348
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+277
-348
lines changed

apollo-adminservice/pom.xml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,15 @@
2222
<!-- end of apollo -->
2323
<dependency>
2424
<groupId>org.springframework.cloud</groupId>
25-
<artifactId>spring-cloud-starter-eureka-server</artifactId>
25+
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
2626
<scope>test</scope>
2727
<exclusions>
2828
<exclusion>
29-
<artifactId>
30-
spring-cloud-starter-archaius
31-
</artifactId>
29+
<artifactId>spring-cloud-starter-netflix-archaius</artifactId>
3230
<groupId>org.springframework.cloud</groupId>
3331
</exclusion>
3432
<exclusion>
35-
<artifactId>spring-cloud-starter-ribbon</artifactId>
33+
<artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
3634
<groupId>org.springframework.cloud</groupId>
3735
</exclusion>
3836
<exclusion>

apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/AdminServiceHealthIndicator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public Health health() {
2424
}
2525

2626
private int check() {
27-
PageRequest pageable = new PageRequest(0, 1);
27+
PageRequest pageable = PageRequest.of(0, 1);
2828
appService.findAll(pageable);
2929
return 0;
3030
}

apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/InstanceConfigController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public long getInstancesCountByNamespace(@RequestParam("appId") String appId,
183183
@RequestParam("clusterName") String clusterName,
184184
@RequestParam("namespaceName") String namespaceName) {
185185
Page<Instance> instances = instanceService.findInstancesByNamespace(appId, clusterName,
186-
namespaceName, new PageRequest(0, 1));
186+
namespaceName, PageRequest.of(0, 1));
187187
return instances.getTotalElements();
188188
}
189189
}

apollo-adminservice/src/main/resources/adminservice.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ spring.application.name= apollo-adminservice
33
ctrip.appid= 100003172
44
server.port= 8090
55
logging.file= /opt/logs/100003172/apollo-adminservice.log
6+
spring.jmx.default-domain = apollo-adminservice

apollo-adminservice/src/main/resources/bootstrap.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,16 @@ eureka:
22
instance:
33
hostname: ${hostname:localhost}
44
preferIpAddress: true
5+
status-page-url-path: /info
6+
health-check-url-path: /health
57
client:
68
serviceUrl:
79
defaultZone: http://${eureka.instance.hostname}:8080/eureka/
810
healthcheck:
911
enabled: true
1012
eurekaServiceUrlPollIntervalSeconds: 60
1113

12-
endpoints:
13-
health:
14-
sensitive: false
15-
16-
17-
1814
management:
19-
security:
20-
enabled: false
2115
health:
2216
status:
2317
order: DOWN, OUT_OF_SERVICE, UNKNOWN, UP

apollo-adminservice/src/main/scripts/startup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ declare -i max_counter=48 # 48*5=240s
9999
declare -i total_time=0
100100

101101
printf "Waiting for server startup"
102-
until [[ (( counter -ge max_counter )) || "$(curl -X GET --silent --connect-timeout 1 --max-time 2 --head $SERVER_URL | grep "Coyote")" != "" ]];
102+
until [[ (( counter -ge max_counter )) || "$(curl -X GET --silent --connect-timeout 1 --max-time 2 --head $SERVER_URL | grep "HTTP")" != "" ]];
103103
do
104104
printf "."
105105
counter+=1

apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/controller/AbstractControllerTest.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,24 @@
55
import org.junit.runner.RunWith;
66
import org.springframework.beans.factory.annotation.Autowired;
77
import org.springframework.beans.factory.annotation.Value;
8-
import org.springframework.boot.autoconfigure.web.HttpMessageConverters;
9-
import org.springframework.boot.test.SpringApplicationConfiguration;
10-
import org.springframework.boot.test.TestRestTemplate;
11-
import org.springframework.boot.test.WebIntegrationTest;
8+
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
9+
import org.springframework.boot.test.context.SpringBootTest;
10+
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
11+
import org.springframework.boot.test.web.client.TestRestTemplate;
1212
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
1313
import org.springframework.web.client.DefaultResponseErrorHandler;
1414
import org.springframework.web.client.RestTemplate;
1515

1616
import javax.annotation.PostConstruct;
1717

1818
@RunWith(SpringJUnit4ClassRunner.class)
19-
@SpringApplicationConfiguration(classes = AdminServiceTestConfiguration.class)
20-
@WebIntegrationTest(randomPort = true)
19+
@SpringBootTest(classes = AdminServiceTestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT)
2120
public abstract class AbstractControllerTest {
2221

2322
@Autowired
2423
private HttpMessageConverters httpMessageConverters;
2524

26-
RestTemplate restTemplate = new TestRestTemplate();
25+
protected RestTemplate restTemplate = (new TestRestTemplate()).getRestTemplate();
2726

2827
@PostConstruct
2928
private void postConstruct() {

apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/controller/AppControllerTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public void testCreate() {
5353
Assert.assertEquals(dto.getAppId(), result.getAppId());
5454
Assert.assertTrue(result.getId() > 0);
5555

56-
App savedApp = appRepository.findOne(result.getId());
56+
App savedApp = appRepository.findById(result.getId()).orElse(null);
5757
Assert.assertEquals(dto.getAppId(), savedApp.getAppId());
5858
Assert.assertNotNull(savedApp.getDataChangeCreatedTime());
5959
}
@@ -69,7 +69,7 @@ public void testCreateTwice() {
6969
Assert.assertEquals(dto.getAppId(), first.getAppId());
7070
Assert.assertTrue(first.getId() > 0);
7171

72-
App savedApp = appRepository.findOne(first.getId());
72+
App savedApp = appRepository.findById(first.getId()).orElse(null);
7373
Assert.assertEquals(dto.getAppId(), savedApp.getAppId());
7474
Assert.assertNotNull(savedApp.getDataChangeCreatedTime());
7575

@@ -108,7 +108,7 @@ public void testDelete() {
108108

109109
restTemplate.delete("http://localhost:{port}/apps/{appId}?operator={operator}", port, app.getAppId(), "test");
110110

111-
App deletedApp = appRepository.findOne(app.getId());
111+
App deletedApp = appRepository.findById(app.getId()).orElse(null);
112112
Assert.assertNull(deletedApp);
113113
}
114114

apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/controller/ControllerExceptionTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public void testDeleteNotExists() {
5656
@Test
5757
public void testFindEmpty() {
5858
when(appService.findAll(any(Pageable.class))).thenReturn(new ArrayList<App>());
59-
Pageable pageable = new PageRequest(0, 10);
59+
Pageable pageable = PageRequest.of(0, 10);
6060
List<AppDTO> appDTOs = appController.find(null, pageable);
6161
Assert.assertNotNull(appDTOs);
6262
Assert.assertEquals(0, appDTOs.size());
@@ -68,7 +68,7 @@ public void testFindEmpty() {
6868

6969
@Test
7070
public void testFindByName() {
71-
Pageable pageable = new PageRequest(0, 10);
71+
Pageable pageable = PageRequest.of(0, 10);
7272
List<AppDTO> appDTOs = appController.find("unexist", pageable);
7373
Assert.assertNotNull(appDTOs);
7474
Assert.assertEquals(0, appDTOs.size());

apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/controller/InstanceConfigControllerTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.mockito.runners.MockitoJUnitRunner;
2121
import org.springframework.data.domain.Page;
2222
import org.springframework.data.domain.PageImpl;
23+
import org.springframework.data.domain.PageRequest;
2324
import org.springframework.data.domain.Pageable;
2425
import org.springframework.test.util.ReflectionTestUtils;
2526

@@ -47,14 +48,15 @@ public class InstanceConfigControllerTest {
4748
@Mock
4849
private InstanceService instanceService;
4950

50-
@Mock
5151
private Pageable pageable;
5252

5353
@Before
5454
public void setUp() throws Exception {
5555
instanceConfigController = new InstanceConfigController();
5656
ReflectionTestUtils.setField(instanceConfigController, "releaseService", releaseService);
5757
ReflectionTestUtils.setField(instanceConfigController, "instanceService", instanceService);
58+
59+
pageable = PageRequest.of(0, 2);
5860
}
5961

6062
@Test
@@ -230,7 +232,6 @@ public void testGetInstancesByNamespace() throws Exception {
230232
String someIp = "someIp";
231233
long someInstanceId = 1;
232234
long anotherInstanceId = 2;
233-
Pageable pageable = mock(Pageable.class);
234235

235236
Instance someInstance = assembleInstance(someInstanceId, someAppId, someClusterName,
236237
someNamespaceName, someIp);
@@ -270,7 +271,6 @@ public void testGetInstancesByNamespaceAndInstanceAppId() throws Exception {
270271
String someIp = "someIp";
271272
long someInstanceId = 1;
272273
long anotherInstanceId = 2;
273-
Pageable pageable = mock(Pageable.class);
274274

275275
Instance someInstance = assembleInstance(someInstanceId, someAppId, someClusterName,
276276
someNamespaceName, someIp);
@@ -352,4 +352,4 @@ private InstanceConfig assembleInstanceConfig(long instanceId, String configAppI
352352
instanceConfig.setReleaseDeliveryTime(releaseDeliveryTime);
353353
return instanceConfig;
354354
}
355-
}
355+
}

apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/controller/ItemSetControllerTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import org.junit.Assert;
1212
import org.junit.Test;
1313
import org.springframework.beans.factory.annotation.Autowired;
14-
import org.springframework.boot.test.TestRestTemplate;
14+
import org.springframework.boot.test.web.client.TestRestTemplate;
1515
import org.springframework.http.HttpStatus;
1616
import org.springframework.http.ResponseEntity;
1717
import org.springframework.test.context.jdbc.Sql;
@@ -47,7 +47,7 @@ public void testItemSetCreated() {
4747

4848
ItemChangeSets itemSet = new ItemChangeSets();
4949
itemSet.setDataChangeLastModifiedBy("created");
50-
RestTemplate createdTemplate = new TestRestTemplate();
50+
RestTemplate createdTemplate = (new TestRestTemplate()).getRestTemplate();
5151
createdTemplate.setMessageConverters(restTemplate.getMessageConverters());
5252

5353
int createdSize = 3;
@@ -96,7 +96,7 @@ public void testItemSetUpdated() {
9696

9797
ItemChangeSets createChangeSet = new ItemChangeSets();
9898
createChangeSet.setDataChangeLastModifiedBy("created");
99-
RestTemplate createdRestTemplate = new TestRestTemplate();
99+
RestTemplate createdRestTemplate = (new TestRestTemplate()).getRestTemplate();
100100
createdRestTemplate.setMessageConverters(restTemplate.getMessageConverters());
101101

102102
int createdSize = 3;
@@ -123,7 +123,7 @@ public void testItemSetUpdated() {
123123
ItemChangeSets updateChangeSet = new ItemChangeSets();
124124
updateChangeSet.setDataChangeLastModifiedBy("updated");
125125

126-
RestTemplate updatedRestTemplate = new TestRestTemplate();
126+
RestTemplate updatedRestTemplate = (new TestRestTemplate()).getRestTemplate();
127127
updatedRestTemplate.setMessageConverters(restTemplate.getMessageConverters());
128128

129129
int updatedSize = 2;
@@ -170,7 +170,7 @@ public void testItemSetDeleted() {
170170

171171
ItemChangeSets createChangeSet = new ItemChangeSets();
172172
createChangeSet.setDataChangeLastModifiedBy("created");
173-
RestTemplate createdTemplate = new TestRestTemplate();
173+
RestTemplate createdTemplate = (new TestRestTemplate()).getRestTemplate();
174174
createdTemplate.setMessageConverters(restTemplate.getMessageConverters());
175175

176176
int createdSize = 3;
@@ -196,7 +196,7 @@ public void testItemSetDeleted() {
196196

197197
ItemChangeSets deleteChangeSet = new ItemChangeSets();
198198
deleteChangeSet.setDataChangeLastModifiedBy("deleted");
199-
RestTemplate deletedTemplate = new TestRestTemplate();
199+
RestTemplate deletedTemplate = (new TestRestTemplate()).getRestTemplate();
200200
deletedTemplate.setMessageConverters(restTemplate.getMessageConverters());
201201

202202
int deletedSize = 1;

apollo-adminservice/src/test/resources/application.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
spring.datasource.url = jdbc:h2:mem:~/apolloconfigdb;mode=mysql;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1
2-
spring.jpa.hibernate.naming_strategy=org.hibernate.cfg.EJB3NamingStrategy
2+
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
33
spring.jpa.properties.hibernate.show_sql=false
44
spring.h2.console.enabled = true
55
spring.h2.console.settings.web-allow-others=true
Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
eureka:
22
instance:
33
hostname: ${hostname:localhost}
4+
preferIpAddress: true
5+
status-page-url-path: /info
6+
health-check-url-path: /health
47
client:
58
serviceUrl:
69
defaultZone: http://${eureka.instance.hostname}:8090/eureka/
710
healthcheck:
811
enabled: true
912

10-
11-
endpoints:
12-
health:
13-
sensitive: false
14-
1513
management:
16-
security:
17-
enabled: false
1814
health:
1915
status:
2016
order: DOWN, OUT_OF_SERVICE, UNKNOWN, UP

apollo-assembly/src/main/java/com/ctrip/framework/apollo/assembly/ApolloApplication.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import org.slf4j.Logger;
88
import org.slf4j.LoggerFactory;
9+
import org.springframework.boot.WebApplicationType;
910
import org.springframework.boot.autoconfigure.SpringBootApplication;
1011
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
1112
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
@@ -24,7 +25,7 @@ public static void main(String[] args) throws Exception {
2425
* Common
2526
*/
2627
ConfigurableApplicationContext commonContext =
27-
new SpringApplicationBuilder(ApolloApplication.class).web(false).run(args);
28+
new SpringApplicationBuilder(ApolloApplication.class).web(WebApplicationType.NONE).run(args);
2829
logger.info(commonContext.getId() + " isActive: " + commonContext.isActive());
2930

3031
/**

apollo-assembly/src/test/java/com/ctrip/framework/apollo/assembly/LocalApolloApplication.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import org.slf4j.Logger;
88
import org.slf4j.LoggerFactory;
9+
import org.springframework.boot.WebApplicationType;
910
import org.springframework.boot.autoconfigure.SpringBootApplication;
1011
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
1112
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
@@ -24,7 +25,7 @@ public static void main(String[] args) throws Exception {
2425
* Common
2526
*/
2627
ConfigurableApplicationContext commonContext =
27-
new SpringApplicationBuilder(ApolloApplication.class).web(false).run(args);
28+
new SpringApplicationBuilder(ApolloApplication.class).web(WebApplicationType.NONE).run(args);
2829
logger.info(commonContext.getId() + " isActive: " + commonContext.isActive());
2930

3031
/**

apollo-assembly/src/test/resources/application.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
spring.datasource.url = jdbc:h2:mem:~/apolloconfigdb;mode=mysql;DB_CLOSE_ON_EXIT=FALSE
2-
spring.jpa.hibernate.naming_strategy=org.hibernate.cfg.EJB3NamingStrategy
2+
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
33
spring.jpa.properties.hibernate.show_sql=false
44
spring.h2.console.enabled = true
55
spring.h2.console.settings.web-allow-others=true

apollo-biz/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<!-- eureka -->
2222
<dependency>
2323
<groupId>org.springframework.cloud</groupId>
24-
<artifactId>spring-cloud-starter-eureka</artifactId>
24+
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
2525
</dependency>
2626
<!-- end of eureka -->
2727
<dependency>

apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Instance.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import javax.persistence.Column;
88
import javax.persistence.Entity;
99
import javax.persistence.GeneratedValue;
10+
import javax.persistence.GenerationType;
1011
import javax.persistence.Id;
1112
import javax.persistence.PrePersist;
1213
import javax.persistence.Table;
@@ -18,7 +19,7 @@
1819
@Table(name = "Instance")
1920
public class Instance {
2021
@Id
21-
@GeneratedValue
22+
@GeneratedValue(strategy = GenerationType.IDENTITY)
2223
@Column(name = "Id")
2324
private long id;
2425

apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/InstanceConfig.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import javax.persistence.Column;
88
import javax.persistence.Entity;
99
import javax.persistence.GeneratedValue;
10+
import javax.persistence.GenerationType;
1011
import javax.persistence.Id;
1112
import javax.persistence.PrePersist;
1213
import javax.persistence.PreUpdate;
@@ -19,7 +20,7 @@
1920
@Table(name = "InstanceConfig")
2021
public class InstanceConfig {
2122
@Id
22-
@GeneratedValue
23+
@GeneratedValue(strategy = GenerationType.IDENTITY)
2324
@Column(name = "Id")
2425
private long id;
2526

apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ReleaseMessage.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import javax.persistence.Column;
88
import javax.persistence.Entity;
99
import javax.persistence.GeneratedValue;
10+
import javax.persistence.GenerationType;
1011
import javax.persistence.Id;
1112
import javax.persistence.PrePersist;
1213
import javax.persistence.Table;
@@ -18,7 +19,7 @@
1819
@Table(name = "ReleaseMessage")
1920
public class ReleaseMessage {
2021
@Id
21-
@GeneratedValue
22+
@GeneratedValue(strategy = GenerationType.IDENTITY)
2223
@Column(name = "Id")
2324
private long id;
2425

0 commit comments

Comments
 (0)